Bug Tracker

Modify

Ticket #3185 (closed bug: duplicate)

Opened 5 years ago

Last modified 14 months ago

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:
Blocking: Blocked by:

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

comment:1 Changed 5 years ago by flesler

  • Component changed from core to event

You can just set

jQuery.isReady = true;

Right after you load jQuery.

comment:2 Changed 4 years ago by dmethvin

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

Dup of #2509.

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.