X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=19bb4f6a3528c513acba255283c4f7a24aa34c49;hb=32816eff59095841e078cf5a7bf637ea64c4c801;hp=a60c4616aff29c624e66f61b69a65a84002bbeed;hpb=af961d58c244224c14f3bb519214485cb670c64d;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index a60c461..19bb4f6 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -1592,20 +1592,16 @@ new function(){ // Finally, handle events that only fire once jQuery.fn["one"+o] = function(f){ - // Attach the event listener - return this.each(function(){ - - var count = 0; - - // Add the event - jQuery.event.add( this, o, function(e){ - // If this function has already been executed, stop - if ( count++ ) return true; - - // And execute the bound function - return f.apply(this, [e]); - }); - }); + // save cloned reference to this + var element = jQuery(this); + var handler = function() { + // unbind itself when executed + element.unbind(o, handler); + element = null; + // apply original handler with the same arguments + f.apply(this, arguments); + }; + return this.bind(o, handler); }; }; @@ -1625,11 +1621,12 @@ new function(){ // Use the defer script hack var script = document.getElementById("__ie_init"); - script.onreadystatechange = function() { - if ( this.readyState != "complete" ) return; - this.parentNode.removeChild( this ); - jQuery.ready(); - }; + if (script) // script does not exist if jQuery is loaded dynamically + script.onreadystatechange = function() { + if ( this.readyState != "complete" ) return; + this.parentNode.removeChild( this ); + jQuery.ready(); + }; // Clear from memory script = null;