Last active
December 20, 2015 14:29
-
-
Save sTiLL-iLL/6146597 to your computer and use it in GitHub Desktop.
custom eventing
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
//create event | |
var minE = new CustomEvent("yourEventName", { | |
detail: { | |
"key": value | |
}, | |
bubbles: true, | |
cancelable: true | |
}); | |
//add handler | |
targetElement.addEventListener("yourEventName", function(e) { | |
alert("event = ", e); | |
alert("event data = ", e.detail); | |
}); | |
// trigger | |
targetElement.dispatchEvent(minE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment