Fixed issues with oneEvent events.
This commit is contained in:
parent
7d57c67749
commit
f5f6cbc8c0
1 changed files with 11 additions and 10 deletions
|
@ -120,18 +120,19 @@ 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;
|
||||||
|
|
||||||
|
// Add the event
|
||||||
|
jQuery.event.add( this, o, function(e){
|
||||||
// If this function has already been executed, stop
|
// If this function has already been executed, stop
|
||||||
if ( this[o+f] !== null ) return;
|
if ( count++ ) return;
|
||||||
|
|
||||||
// Otherwise, mark as having been executed
|
|
||||||
this[o+f]++;
|
|
||||||
|
|
||||||
// And execute the bound function
|
// And execute the bound function
|
||||||
return f.apply(this, [e]);
|
return f.apply(this, [e]);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue