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 -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -