Skip to content

Commit

Permalink
Close GH-659: Allow event handlers registered with one() to be remove…
Browse files Browse the repository at this point in the history
…d with off().. Fixes #658
  • Loading branch information
cne-opsadmin authored and heff committed Jul 29, 2013
1 parent a809954 commit 334ff59
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,10 @@ vjs.trigger = function(elem, event) {
* @return {[type]}
*/
vjs.one = function(elem, type, fn) {
vjs.on(elem, type, function(){
vjs.off(elem, type, arguments.callee);
var func = function(){
vjs.off(elem, type, func);
fn.apply(this, arguments);
});
};
func.guid = fn.guid = fn.guid || vjs.guid++;
vjs.on(elem, type, func);
};

0 comments on commit 334ff59

Please sign in to comment.