diff options
author | John Resig <jeresig@gmail.com> | 2006-10-26 16:09:55 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2006-10-26 16:09:55 +0000 |
commit | 476cbd2f1afd39e32feb350a732877c18f9f7715 (patch) | |
tree | 4f9c1258ac74495ee53ff69ed31f1eccc3399ee3 /src/event | |
parent | 44e4b36c083fd0728c5a73c7b71b118c336eb5d7 (diff) | |
download | jquery-476cbd2f1afd39e32feb350a732877c18f9f7715.tar.gz jquery-476cbd2f1afd39e32feb350a732877c18f9f7715.zip |
Rolled back Joern's changes. They've been moved to another branch, and will be merged for 1.1.
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/event.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/event/event.js b/src/event/event.js index 55e205ae2..a60c4616a 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,20 @@ 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); + // 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]); + }); + }); }; }; |