Skip to content

Instantly share code, notes, and snippets.

@madeinspace
Created September 25, 2012 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madeinspace/3779310 to your computer and use it in GitHub Desktop.
Save madeinspace/3779310 to your computer and use it in GitHub Desktop.
Javascript custom event
//Listen to custom event
document.addEventListener("myCustomEvent", function(e) {
var object = e.detail.object;
log(e.detail.object +" has dispatched event: "+e);
});
// Dispatch custom event
this.myevent.initEvent("myCustomEvent", true, true);
this.myevent.detail = { object: this}
document.dispatchEvent(this.myevent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment