Here is my code to create a custom event that is working:
var evt = document.createEvent("Event"); //creat custom event
evt.initEvent("fac_sel", true, true); //initialize the event
evt.objIndex = "some test data"; //add custom data
document.dispatchEvent(evt); //fire event!
For some reason the following code results in "undefined"
document.removeEventListener("Event","fac_sel", true);
The addEventListener and removeEventListener methods do not return anything. Hence the call document.removeEventListener("Event", "fac_sel", true) will display as undefined in a debugger or assign undefined to a variable.
Check out the removeEventListener method on MDN for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With