Modify ↓
Ticket #1989 (closed feature: fixed)
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: | ||
| Blocking: | Blocked by: |
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.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

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.