aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2006-07-16 00:52:30 +0000
committerJohn Resig <jeresig@gmail.com>2006-07-16 00:52:30 +0000
commitf5f6cbc8c0b6441fb1d106749f7124659a3816f0 (patch)
tree7a59b8e93987e7296bca3114a130d736cb491bb8
parent7d57c67749a4c38d80de6d5ed7917f4219ce34b4 (diff)
downloadjquery-f5f6cbc8c0b6441fb1d106749f7124659a3816f0.tar.gz
jquery-f5f6cbc8c0b6441fb1d106749f7124659a3816f0.zip
Fixed issues with oneEvent events.
-rw-r--r--event/event.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/event/event.js b/event/event.js
index 0c7b0b1b3..70cfb8693 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]);
+ });
});
};