Bug Tracker

Modify

Ticket #1989 (closed feature: fixed)

Opened 5 years ago

Last modified 4 years ago

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

comment:1 Changed 5 years ago by davidserduke

  • Type changed from bug to feature

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.

comment:2 Changed 5 years ago by john

  • Component changed from core to ajax

comment:3 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.