Skip to content

Instantly share code, notes, and snippets.

@arian
Created July 1, 2010 20:38
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arian/460529 to your computer and use it in GitHub Desktop.
Save arian/460529 to your computer and use it in GitHub Desktop.
// Add an outer click Event to an Element
// http://cpojer.net/blog/Custom_outerClick_event (but this page doesn't exist anymore)
Element.Events.outerClick = {
base: 'click',
condition: function(event){
event.stopPropagation();
return false;
},
onAdd: function(fn){
this.getDocument().addEvent('click', fn);
},
onRemove: function(fn){
this.getDocument().removeEvent('click', fn);
}
};
$('test').addEvent('outerClick', function(){
// you clicked outside $('test')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment