Bug Tracker

Ticket #3185 (new bug)

Opened 6 months ago

Last modified 6 months ago

ready() doesn't work correctly for scripts loaded dynamically

Reported by: natrius Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.3 Component: event
Version: 1.2.6 Keywords:
Cc: Needs: Review

Description

Consider a page that does not call ready(). If ready() is called by a script that is dynamically loaded on such a page after it has already been loaded, the function passed to ready() will never be called (in Firefox 3). DOMContentLoaded is apparently not fired for elements inserted after the original page load, and since the listener for that event isn't attached until the first call to ready(), jQuery never calls the function. My current workaround is to include a dummy call to ready() in all of my pages where this problem manifests itself so jQuery will catch DOMContentLoaded for the initial page load, and the function I'm passing to ready() from the dynamically loaded HTML will just fire immediately. (This might make you wonder why I bother using ready() at all. It's complicated.)

Although my use case is rather strange, this still seems like undesirable behavior.

Attachments

Change History

Changed 6 months ago by flesler

  • owner deleted
  • component changed from core to event

You can just set

jQuery.isReady = true;

Right after you load jQuery.

Note: See TracTickets for help on using tickets.