javascript - How do I properly restrict a .on('click tap') event from triggering more than once per click? -


i'm developing application on phonegap screen has cancel button.

the cancel button needs have click/tap event listener cancels form submission , returns previous page on application.

the application needs compatible both mobile devices (such tablets) , modern day browsers. why listen both click events tap events.

this how have event listener defined...

$(cancel_button).on('click tap', function(event) {     // assumed following line fix issue, doesn't.     event.stopimmediatepropagation();      goback();     alert("your submission has been cancelled."); }); 

so when click cancel button on browser runs code inside listener 6 times. have idea on how solve this?

maybe try

$(cancel_button).on('click touchend', function(event) {      event.preventdefault();      goback();     alert("your submission has been cancelled."); }); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -