javascript - Manually trigger an event on window object -
i adding listener so:
window.addeventlistener('native.showkeyboard', function (e) { ... ... });
i'm writing unit test want trigger event. im doing:
window.trigger('native.showkeyboard');
but end error line saying:
undefined not function
how can manually trigger event?
edit
i have tried:
$(window).trigger('native.showkeyboard');
but handler doesnt run it's not registered jquery...
if triggering event via jquery
event ought have been attached via jquery
-- see @frederichamidi's comment.
$(window).on('native.showkeyboard', function (e) { ......... }); $(window).trigger('native.showkeyboard');
or if you're using plain vanilla js way:
window.addeventlistener('native.showkeyboard', function (e) { ........ }); window.dispatchevent( new event('native.showkeyboard') );
Comments
Post a Comment