public

  • Download Gist
ClickOut Custom Event for MooTools 1.2
Groff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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
*/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.