Skip to content

Instantly share code, notes, and snippets.

@arian
Created July 12, 2010 21:48
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 arian/473116 to your computer and use it in GitHub Desktop.
Save arian/473116 to your computer and use it in GitHub Desktop.
// prototypejs element delegation for mootools
// http://api.prototypejs.org/dom/element/on/
(function(addEvent, removeEvent){
var args = arguments;
['add', 'remove'].each(function(method, l){
Element.implement(method + 'Event', function(type, selector, fn){
if(typeof selector == 'function') fn = selector;
else type = type + ':relay('+selector+')';
args[l].apply(this, [type, fn]);
});
});
})(Element.prototype.addEvent, Element.prototype.removeEvent);
$(document.body).addEvent('click', 'a', function(){
alert('hi');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment