滑动事件触发了针对ipod touch的点击事件 [英] Swipe event triggers tap event for ipod touch
问题描述
我正在使用jquery mobile beta和jquery 1.6。
在ipod touch上,滑动事件也会触发点击事件。
这个问题不是在Android设备上。
我试图谷歌解决方案,但看起来没有很多同样的问题。我有什么非常基本的东西吗?
I am using jquery mobile beta and jquery 1.6. On ipod touch, a swipe event is also trigerring the tap event. This issue is not hapenning on android devices. I am trying to google out the solution, but looks like there are not many with the same problem. Is there something very basic that I am missing??
$("div.totapandswipe").bind('tap',function(event, ui){
alert('event');
});
$("div.totapandswipe").bind('swipe',function(event, ui){
alert('event');
});
感谢您的帮助!
推荐答案
我发现我需要取消绑定('click')作为我的绑定('swipeleft swiperight')函数中的第一个选项。由于我的滑动转到新页面,该页面重新绑定它刚刚离开的页面的点击事件。我的实用程序是一个闪存卡,水龙头带来一张新卡并轻扫翻转它。祝你好运。
I have found that I needed to unbind('click') as the first option in my bind('swipeleft swiperight') function. Since my swipe goes to a new page, that page re-binds the 'click' event for the page that it just left. My utility is a flashcard that tap brings a new card and swiping flips it over. Good luck.
$('#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 ');
});
});
这篇关于滑动事件触发了针对ipod touch的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!