Skip to content

Instantly share code, notes, and snippets.

@3n
Created April 4, 2009 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3n/90053 to your computer and use it in GitHub Desktop.
Save 3n/90053 to your computer and use it in GitHub Desktop.
/*
Script: Event.addEventOnce.js
Extends the Event class (using .implement) with a method to add an event only once.
*/
Event.implement({
addEventOnce: function(type, func){
this.addEvent(type, function(e){ func(e); this.removeEvent(type, arguments.callee) });
return this;
}
});
Native.implement([Element, Window, Document], {
addEventOnce: Event.prototype.addEventOnce
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment