Created
January 31, 2012 13:39
-
-
Save juanghurtado/1710537 to your computer and use it in GitHub Desktop.
jQuery namespaced events binding and unbinding
This file contains 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
jQuery(function() { | |
jQuery('a').bind('click.custom_namespace', function() { | |
alert("Oh my god, I'm gonna be unbinded later!"); | |
}); | |
jQuery('a').bind('click', function() { | |
alert("I'm Chuck Norris, and I approve this bind."); | |
}); | |
jQuery('a').unbind('click.custom_namespace'); | |
// When clicking a link, we'll get an alert with | |
// "I'm Chuck Norris, and I approve this bind." | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment