javascript - How check if custom event was prevented -


in code need interact custom event after dispatched

// ... let customevent = new customevent('myevent', {   bubbles: true,   cancelable: true });  button.addeventlistener('click', function (e) {   e.preventdefault();   otherelement.dispatchevent( customevent );   // @ point neeed   // if ( customevent canceled or prevented ) { } }); 

how can check if has been prevented/canceled or solution "feedback" event?

lots of ways this. 1 way:

var iscanceled = !otherelement.dispatchevent(event); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -