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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -