Commit f5f6cbc8 authored by John Resig's avatar John Resig

Fixed issues with oneEvent events.

parent 7d57c677
...@@ -120,17 +120,18 @@ new function(){ ...@@ -120,17 +120,18 @@ new function(){
// Finally, handle events that only fire once // Finally, handle events that only fire once
jQuery.fn["one"+o] = function(f){ jQuery.fn["one"+o] = function(f){
// Attach the event listener // Attach the event listener
return this.bind(o, function(e){ return this.each(function(){
// TODO: Remove the event listener, instead of this hack
var count = 0;
// If this function has already been executed, stop
if ( this[o+f] !== null ) return; // Add the event
jQuery.event.add( this, o, function(e){
// Otherwise, mark as having been executed // If this function has already been executed, stop
this[o+f]++; if ( count++ ) return;
// And execute the bound function // And execute the bound function
return f.apply(this, [e]); return f.apply(this, [e]);
});
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment