ionicPopup tapped twice


#1

Hi all,

I’m having some issues with $ionicPopup. I have a popup with a button and an onTap event attached to the button. So when I click the button a counter is increased. I’m testing my ionic app in a PC (chrome browser). The problem appears when I click very fast the button (two or more times). In this situation, the onTap function is executed two or more times and my counter is increased in more than one.

Do you know any way of controlling the fast clicks in the button for calling only once the onTap function?

Thank you,
Torettto.


#2

I’m having the same issue. onTap is triggered several times when clicking button in ionicPopup fast. I get this problem both in in Chrome and on my device (Android).

Ionic has implemented methods to prevent this in other places, for example try clicking many times on any other item with a ng-click attribute and you will only get one trigger of the function (see http://blog.ionic.io/hybrid-apps-and-the-curse-of-the-300ms-delay/). But onTap doesnt seem to be included in this.

A workaround could be to put your counter in the then or catch clause of the promise returned by $ionicPopup which only seems to trigger once. But then you potentially need to return different values from your buttons to find out what code to run (if you have different code for different buttons that you end up putting in the then/catch).

Also see http://codepen.io/asmund/pen/LNZdqx for an example of the behavior. Select “Show” and then click the “Save” button several times fast to get several “Save clicked” in your developer console, but just one “Tapped”.