morrisbret
morrisbret

Reputation: 203

jQTouch Event Fires Twice

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);
}

$('#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!

Upvotes: 2

Views: 855

Answers (2)

Ben Developer
Ben Developer

Reputation: 166

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.

  1. First do unbind.....exL .unbind('click').click(function(){});
  2. 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.

Upvotes: 0

NealJMD
NealJMD

Reputation: 894

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.

Upvotes: 1

Related Questions