Events Android emulator上的JQuery移动刷卡事件有时才起作用(使用PhoneGap)
我这样添加了swipeleft和swiperight侦听器Events Android emulator上的JQuery移动刷卡事件有时才起作用(使用PhoneGap),events,jquery-mobile,cordova,android-emulator,Events,Jquery Mobile,Cordova,Android Emulator,我这样添加了swipeleft和swiperight侦听器 $("#slides li").swipeleft(function(){ console.log("!!!! swipe left"); }); $("#slides li").swiperight(function(){ console.log("!!!! swipe right"); }); 它有时有效,但大部分无效。我没有做任何不同的事情 我使用的是PhoneGap 1.4.
$("#slides li").swipeleft(function(){
console.log("!!!! swipe left");
});
$("#slides li").swiperight(function(){
console.log("!!!! swipe right");
});
它有时有效,但大部分无效。我没有做任何不同的事情
我使用的是PhoneGap 1.4.0、JQuery mobile 1.0和JQuery min 1.7.1
有什么想法吗。。。?提前感谢。由于缓存的工作方式,移动浏览器通常在
id
属性上存在问题。这意味着id
属性并不总是唯一的,即使在页面上只使用一次
您可以尝试将刷卡事件绑定到类
,以避免此类问题。它可能看起来像这样:
$('.slides').bind('swiperight',function(event, info){
console.log("!!!! swipe right");
});
jquerymobile在javascript代码中也有一些常量,用于定义它对不同手势(如刷卡)的敏感程度。您可能需要更改这些常量,使应用程序对刷卡事件更加敏感。在IOS中,它与ids配合良好。过了一段时间,不知道为什么,它也开始在我的android模拟器中运行良好。