Skip to main content

Bug Tracker

Side navigation

#1989 closed feature (fixed)

Opened November 28, 2007 10:35PM UTC

Closed January 31, 2009 04:16PM UTC

If page loaded with $(sel).load(url) contains Javascript it may not propertly execute

Reported by: gstolarov Owned by:
Priority: major Milestone: 1.2.2
Component: ajax Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

Since all the nodes loaded with $().load() evaluated in sequence, Javascript elements referring to the following page elements will fail. E.g if following page is loaded using $("#xxx).load(url) it will fail:

<script>$("#yyy").click( function() { alert('in here!...'); }); </script>

<span id="yyy">click</span>

Where as following page will work:

<span id="yyy">click</span>

<script>$("#yyy").click( function() { alert('in here!...'); }); </script>

Suggest to evaluate <script/> nodes at after all the elements are processed.

Attachments (0)
Change History (3)

Changed November 30, 2007 05:18AM UTC by davidserduke comment:1

type: bugfeature

This is working as expected. There could be times when you want the script to execute before the dom is inserted. Now, if you are suggesting jQuery add a function that would allow scripts to be in the html before the DOM and be executed after I could see that (similar to $(document).ready() does on startup).

I'm going to guess that is what you want and set this ticket to new feature. I'm not sure what it would take to create it but I like the idea.

Changed December 11, 2007 04:59PM UTC by john comment:2

component: coreajax

Changed January 31, 2009 04:16PM UTC by dmethvin comment:3

resolution: → fixed
status: newclosed

Now works this way in jQuery 1.3; scripts are executed after all DOM content is inserted.