Created
August 2, 2010 19:46
-
-
Save elijahmanor/505197 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
//Using Namespaced Events | |
//When writing jQuery Plugins it is helpful to add a namespace when binding to native or custom events. | |
//You can unbind all events associated with your plugin without affecting other events. | |
//The namespace will not affect triggering custom events. They will work as you would expect. | |
//Use a namespace with your plugin events | |
$("div").bind("click.myPlugin", func1); | |
$("div").bind("keydown.myPlugin", func2); | |
$("div").unbind(".myPlugin"); | |
//Custom events will trigger across namespaces | |
$("div").bind("aCustomEvent.myPlugin", func1); | |
$("div").bind("aCustomEvent.yourPlugin", func2); | |
$("div").trigger("aCustomEvent"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment