X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fevent%2Fevent.js;h=6d889836967004337a188bcced7930789b5154eb;hb=d0eda6827f9bfcf88906e4e45f357cb40e425a05;hp=55e205ae2a6edc1d244eb576eae8a60f1f9f8f6c;hpb=897fbfe89c90de5f20a3eed2aeb187c625cfb43d;p=jquery.git diff --git a/src/event/event.js b/src/event/event.js index 55e205a..6d88983 100644 --- a/src/event/event.js +++ b/src/event/event.js @@ -1583,8 +1583,8 @@ new function(){ var o = e[i]; // Handle event binding - jQuery.fn[o] = function(f, amount){ - return f ? this.bind(o, f, amount) : this.trigger(o); + jQuery.fn[o] = function(f){ + return f ? this.bind(o, f) : this.trigger(o); }; // Handle event unbinding @@ -1592,8 +1592,16 @@ new function(){ // Finally, handle events that only fire once jQuery.fn["one"+o] = function(f){ - // use bind with amount param to bind only once - return this.bind(o, f, 1); + // 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); }; };