jQTouch sometimes fires my click event two times which result in another element (often a link) getting clicked in the panel that shows immediately following a transition.
This issue has been discussed fairly extensively here but there is still not a good solution that I am aware of. In the forum sited above one gentleman suggests the following code as a solution but I am afraid that this will not work for me since I am using swipe and tap events:
allowClick = true;
function preventGhostClick(){
allowClick = false;
setTimeout(function(){
allowClick = true;
},800);
}
$(开发者_如何学Python'#element').bind('tap',function(){
if(!allowClick) return false;
app.utils.preventGhostClick();
// do stuff
});
Does anyone have any experience with this issue and any better solutions than the one above? Much thanks!
Have you tried changing from tap events to either click or touchstart or touchend events? I recall having a very similar problem to this with an iPad webapp and fixing it by changing my events to one of those. Sorry I don't remember specifically, but it's worth a shot.
I'm seeing this issue on iPad only, perhaps related to a version of webkit. I've seen two solutions on the web I wanted to share.
- First do unbind.....exL .unbind('click').click(function(){});
- It seems if jquery code is in the html "head" tag the problem does not exist, but only exists if jquery code in body tag. Perhaps combo of head and body, not sure.
精彩评论