1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-29 11:23:10 +02:00

Close GH-659: Allow event handlers registered with one() to be removed with off().. Fixes #658

This commit is contained in:
David Elner 2013-07-29 15:33:10 -07:00 committed by Steve Heffernan
parent a809954495
commit 334ff59ff0

View File

@ -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);
};