From: John Resig Date: Tue, 9 Nov 2010 18:44:06 +0000 (-0500) Subject: Make sure that if an additional load event is triggered (such as an iframe being... X-Git-Tag: 1.4.4rc3~8 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=983548f8ebc3fcd1bb4600bc4b740cb8a5d4c48b;p=jquery.git Make sure that if an additional load event is triggered (such as an iframe being dynamically injected in DOM ready) the ready event isn't triggered twice. Fixes #7352. --- diff --git a/src/core.js b/src/core.js index 8940ada2b..9e1bfc67f 100644 --- a/src/core.js +++ b/src/core.js @@ -417,18 +417,21 @@ jQuery.extend({ // If there are functions bound, to execute if ( readyList ) { // Execute all of them - var fn, i = 0; - while ( (fn = readyList[ i++ ]) ) { - fn.call( document, jQuery ); - } + var fn, + i = 0, + ready = readyList; // Reset the list of functions readyList = null; - } - // Trigger any bound ready events - if ( jQuery.fn.trigger ) { - jQuery( document ).trigger( "ready" ).unbind( "ready" ); + while ( (fn = ready[ i++ ]) ) { + fn.call( document, jQuery ); + } + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } } } },