I have a strange issue in one of my AngularJS apps. The app uses iCheck for styling checkboxes, and the issue is this: When selecting a checkbox by clicking on its label, while on a mobile phone (or a mobile emulator), the events tied to the checkbox are fired twice.
I've created a JSFiddle where you can reproduce the issue yourself: https://jsfiddle.net/o6oewfff/22/
<input data-icheck data-ng-model="product.selected" id="{{product.id}}" type="checkbox" data-ng-change="callAnEvent()" />
First, take a look at how it's supposed to work:
Now, let's reproduce the issue I'm trying to fix:
Screenshots: https://i.sstatic.net/7j03S.png
As you can see, the events that are logging 'event called' and 'update' to the console are triggered twice when using a mobile. Also, the checkbox is not checked. Is anyone able to figure out why this happens?
Thanks!
Give this one a try https://jsfiddle.net/scdmuout/
I added in the below to stop it firing on the touch and click
event.preventDefault();
event.stopPropagation();