return this.click( jQuery.event.proxy( fn, function( event ) {
// Figure out which function to execute
- this.lastToggle = ( this.lastToggle || 0 ) % i;
+ var lastToggle = ( jQuery.data( this, 'lastToggle' + fn.guid ) || 0 ) % i;
+ jQuery.data( this, 'lastToggle' + fn.guid, lastToggle + 1 );
// Make sure that clicks stop
event.preventDefault();
// and execute the function
- return args[ this.lastToggle++ ].apply( this, arguments ) || false;
+ return args[ lastToggle ].apply( this, arguments ) || false;
}));
},
ready: function() {
// Make sure that the DOM is not already loaded
if ( !jQuery.isReady ) {
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 13 );
+ }
+
// Remember that the DOM is ready
jQuery.isReady = true;
// maybe late but safe also for iframes
document.attachEvent("onreadystatechange", function() {
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" && document.body ) {
+ if ( document.readyState === "complete" ) {
document.detachEvent( "onreadystatechange", arguments.callee );
jQuery.ready();
}
});
- // If IE and not an iframe
+ // If IE and not a frame
// continually check to see if the document is ready
- // NOTE: DO NOT CHANGE TO ===, FAILS IN IE.
- if ( document.documentElement.doScroll && window == window.top ) (function() {
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement === undefined;
+ } catch(e){}
+
+ if ( document.documentElement.doScroll && toplevel ) (function() {
if ( jQuery.isReady ) {
return;
}