Created
August 23, 2017 08:22
-
-
Save luobotang/79f4c5b964fb8dd4ca829a2fa12bc408 to your computer and use it in GitHub Desktop.
DispatchCustomEvent
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
function dispatchCustomEvent(name, data) { | |
var e; | |
if (window.CustomEvent) { | |
e = new window.CustomEvent(name, { | |
canBubble: true, | |
cancelable: true, | |
detail: data | |
}) | |
} else { | |
e = document.createEvent('CustomEvent'); | |
e.initCustomEvent(name, true, true, data) | |
} | |
document.dispatchEvent(e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment