X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=event%2Fevent.js;h=553c568b3d402df80720f8095c062eb9b7898fb0;hb=9e37da96d12c0f35c766a4724c5d565d0a50ab42;hp=0c7b0b1b346fc6c3eff3dac12150553b0228da46;hpb=9477c418dbf50f2341dec7c02f60ab3d77da5378;p=jquery.git diff --git a/event/event.js b/event/event.js index 0c7b0b1..553c568 100644 --- a/event/event.js +++ b/event/event.js @@ -120,17 +120,18 @@ new function(){ // Finally, handle events that only fire once jQuery.fn["one"+o] = function(f){ // Attach the event listener - return this.bind(o, function(e){ - // TODO: Remove the event listener, instead of this hack - - // If this function has already been executed, stop - if ( this[o+f] !== null ) return; - - // Otherwise, mark as having been executed - this[o+f]++; + 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; - // And execute the bound function - return f.apply(this, [e]); + // And execute the bound function + return f.apply(this, [e]); + }); }); }; @@ -147,7 +148,7 @@ new function(){ // Only works if you document.write() it document.write("<\/script>"); + "src=//:><\/script>"); // Use the defer script hack var script = document.getElementById("__ie_init");