Search code examples
jqueryjqtouch

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!


Solution

  • 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.