滑动事件触发了针对ipod touch的点击事件

zoo*_*277 5 jquery tap swipe jquery-mobile

我正在使用jquery mobile beta和jquery 1.6.在ipod touch上,滑动事件也会触发tap事件.这个问题不是在Android设备上.我试图谷歌解决方案,但看起来没有很多同样的问题.我有什么非常基本的东西吗?

$("div.totapandswipe").bind('tap',function(event, ui){
    alert('event');
});

$("div.totapandswipe").bind('swipe',function(event, ui){
            alert('event');
});
Run Code Online (Sandbox Code Playgroud)

感谢您的帮助!

Bri*_*LLC 2

我发现我需要将 unbind('click') 作为 bind('swipeleft swiperight') 函数中的第一个选项。由于我的滑动进入了一个新页面,该页面会重新绑定刚刚离开的页面的“点击”事件。我的实用程序是一张抽认卡,点击即可带来一张新卡,滑动即可将其翻转。祝你好运。

$('#flashVerse').bind('swipeleft swiperight', function(event) {
    console.log(event.type);
    $('#flashVerse').unbind('click');
    if(event.type == 'swipeleft') {
        $.mobile.changePage('flashReference','flip');
    } else {
        $.mobile.changePage('flashReference','flip',true,false);
        console.log('SWIPERIGHT');
    }
});

$('#flashReference').live('pageshow',function(event,ui){
    if((tipsOn() || ls.getItem('tipFlash') == '1') && ui.prevPage.attr('id')!='flashVerse') {
        ls.setItem('tipFlash','0');
        var msg = 'Swipe to flip the card.\n Tap for a new card.\nuse Options to turn Tips back on.';
        if(phoneGap) navigator.notification.alert(msg,dummy,'Flash Cards','OK');
        else alert(msg);
    }
    $('#lnkFlashVerse').addClass('ui-btn-active').addClass('ui-state-persist');
    $('#lnkFlashReference').removeClass('ui-btn-active').removeClass('ui-state-persist');
    $('#flashReference').bind('click', function(event) {
        console.log(event.type);
        newFlashCard();
        //$('#flashReference div[data-role="content"]').append('clicked ');
    });
});
Run Code Online (Sandbox Code Playgroud)