Skip to content

Instantly share code, notes, and snippets.

@juanghurtado
Created January 31, 2012 13:39
Show Gist options
  • Save juanghurtado/1710537 to your computer and use it in GitHub Desktop.
Save juanghurtado/1710537 to your computer and use it in GitHub Desktop.
jQuery namespaced events binding and unbinding
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