Skip to content

Instantly share code, notes, and snippets.

@appden
Created April 7, 2009 20:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save appden/91436 to your computer and use it in GitHub Desktop.
Element.Events.clickout = {
base : 'click',
condition : function(event){
event.stopPropagation(); // stop event bubbling to the body
return false; // never run handler when clicking on element
},
onAdd : function(fn){
this.getDocument().addEvent('click', fn);
},
onRemove : function(fn){
this.getDocument().removeEvent('click', fn);
}
};
/*
Please see for more info:
http://appden.com/javascript/fun-with-custom-events-on-elements-in-mootools/
To see it in action: http://mooshell.net/3AAXb/2
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment