Skip to content

Instantly share code, notes, and snippets.

@tevko
Created November 10, 2015 18:56
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 tevko/4cdfbb1bc4baa605fae0 to your computer and use it in GitHub Desktop.
Save tevko/4cdfbb1bc4baa605fae0 to your computer and use it in GitHub Desktop.
A custom Events utility that works in IE9 and everywhere else
var trigger = function trigger(eventName, elem, data) {
var evt;
data = data || undefined;
try {
evt = new CustomEvent(eventName, {detail: data});
} catch (e) {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(eventName, true, true, data);
}
elem.dispatchEvent(evt);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment