- I have a one page app.
- It uses backbone.js.
- Click events via mouse trigger once.
- Click events via touch device trigger twice.
- Unbinding the one click event stops both on touch devices.
I can't figure out where to start looking.
This is the JS:
$('.classy').on('click', 'button', function(){
console.log('clicked');
})
I need some help figuring out how to trouble shoot this. I know I haven't given enough information to receive a real answer. The confusing part to me is that this only happens on touch devices. If I was accidentally binding two events or creating two instance of the same view it wouldn't it happen for mouse clicks too?
Thank you.
EDIT: I tried using the tap event via jQuery Mobile. This had a strange reaction. It would fire the event once and looked like it was done, but the next time you touch anywhere on the screen it would fire the event again. ...weird, any ideas?
I finally found the problem. It was coming from layered iScrolls. I had to hack the lib at this point, probably a much better way to fix this but illustrates the point.
if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA' && window.iScrollClickFIX != true) {
window.iScrollClickFIX = true;
setTimeout(function(){
window.iScrollClickFIX = false;
}, 1)
Thanks for the help everyone.