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.
I'm using PhoneGap 1.4.0, JQuery mobile 1.0 and JQuery min 1.7.1.
Any ideas...? Thanks in advance.
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 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.