jquery - Add payload to vanilla JavaScript Event -
is there way add payload vanilla javascript event can in jquery?
// jquery $(document).trigger('event', payload); // vanilla js window.dispatchevent(new event('event', ???
i guess have use own event bus of kind?
try utilizing customevent
, see creating , triggering events
function eventhandler(e) { console.log("detail:", e.detail); } window.addeventlistener("build", eventhandler); window.dispatchevent(new customevent("build", {"detail": {"abc":123}}));
Comments
Post a Comment