5

我正在使用 jquery mobile beta 和 jquery 1.6。在 ipod touch 上,滑动事件也会触发点击事件。这个问题在安卓设备上没有发生。我正在尝试用谷歌搜索解决方案,但看起来有同样问题的人并不多。我缺少一些非常基本的东西吗?

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

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

感谢您的帮助!

4

2 回答 2

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 ');
    });
});
于 2011-07-20T15:10:39.967 回答
1

这似乎对我有帮助:

$("selector").swiperight(function (e) {
  if (e.type === "swiperight") {
    myHandler(e);
  }
});

这将是一个问题,这很糟糕。jqm的bug就到此了吗?

于 2011-08-18T14:21:00.853 回答