Skip to content

Instantly share code, notes, and snippets.

@captainbrosset
Created September 23, 2013 13:11
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 captainbrosset/6670191 to your computer and use it in GitHub Desktop.
Save captainbrosset/6670191 to your computer and use it in GitHub Desktop.
Custom events
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>event</title>
</head>
<body>
<div id="live"></div>
<script type="text/javascript">
window.onload = function () {
document.addEventListener("custom", function (event) {
console.log(event);
});
var event;
for(var i = 0; i < 4; i ++) {
event = new CustomEvent("custom", {foo: "bar"});
document.dispatchEvent(event);
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment