Does anyone know why a touchend event would fire during a touchstart event? This only happens the second time around.
A quick code snippet:
function touchstart (event) {
$(event.target).one('touchend', function () {
alert('fired');
}
}
So the first time this is fired it works fine. Second time it fires the alert on touchstart.
http://jsfiddle.net/8SVFR/
Edit:
Looks like this could be an iPhone issue only
Turns out...by having an alert fire in a touchend event causes all sorts of problems. When you click 'ok' it fires the touchstart so the touchend gets fired next time you touch the element. Luckily I was using the alert to check my code - so once this was removed my code worked perfectly!
Just put code of "touchend" handler in setTimeout with 0ms. Like this:
$(someElement).on("touchend",
function(){
setTimeout(function(){
/*Your code*/
}, 0);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With