Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#3185 closed bug (duplicate)

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

Reported by: natrius Owned by:
Priority: major Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:

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.

Change History (2)

comment:1 Changed 11 years ago by flesler

Component: coreevent

You can just set

jQuery.isReady = true;

Right after you load jQuery.

comment:2 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Dup of #2509.

Note: See TracTickets for help on using tickets.