Answers for "javascript emit event"

9

javascript custom events with data

//Listen for the event
window.addEventListener("MyEventType", function(evt) {
    alert(evt.detail);
}, false);

//Dispatch an event
var evt = new CustomEvent("MyEventType", {detail: "Any Object Here"});
window.dispatchEvent(evt);
Posted by: Guest on May-05-2020
0

javascript emit event

const event = new Event('build');

// Listen for the event.
elem.addEventListener('build', function (e) { /* ... */ }, false);

// Dispatch the event.
elem.dispatchEvent(event);
Posted by: Guest on May-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language