在Android模拟器jQuery Mobile的刷卡事件仅有时(使用PhoneGap的) [英] JQuery mobile swipe event on Android emulator works only sometimes (using PhoneGap)

查看:274
本文介绍了在Android模拟器jQuery Mobile的刷卡事件仅有时(使用PhoneGap的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加swipeleft和swiperight听众这样

I added swipeleft and swiperight listeners this way

$("#slides li").swipeleft(function(){
    console.log("!!!! swipe left");
});
$("#slides li").swiperight(function(){      
    console.log("!!!! swipe right");            
});

和它的作品的时候,但是大都没有。我没有做任何的不同。

And it works sometimes, but mostly not. I'm not doing anything different.

我使用的PhoneGap 1.4.0,jQuery Mobile的1.0和JQuery分钟1.7.1。

I'm using PhoneGap 1.4.0, JQuery mobile 1.0 and JQuery min 1.7.1.

任何想法...?先谢谢了。

Any ideas...? Thanks in advance.

推荐答案

移动浏览器一般都用 ID的问题属性,因为他们是如何缓存的工作。这意味着 ID 属性并不总是唯一的,即使你只在页面上使用一次。

Mobile browsers generally have problems with the id attribute, due to how their caching works. This means that the id attribute isn't always unique even though you only use it once on your page.

您可以试试您的刷卡事件绑定到代替你避免这些类型的问题。它可能是这个样子:

You can try to bind your swipe events to a class instead so you avoid those kinds of problems. It may look something like this:

$('.slides').bind('swiperight',function(event, info){
    console.log("!!!! swipe right"); 
});

jQuery Mobile的也有在JavaScript code定义它应该是不同的手势(如刷卡)多么敏感一些常量。你可能想改变这些常量,使您的应用程序刷卡事件更为敏感。

jQuery Mobile also have some constants in the javascript code that defines how sensitive it should be to different gestures (such as swipe). You may want to change these constants to make your application more sensitive to swipe-events.

这篇关于在Android模拟器jQuery Mobile的刷卡事件仅有时(使用PhoneGap的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆