Created
July 1, 2010 20:38
-
-
Save arian/460529 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('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