Reputation: 7025
For the life of me I cannot figure out why I'm not able to change pages in my JQuery mobile document when I swipe right. I know the swipe event is written correctly because when I swap it out with and alert("test");
that fires correctly.
Heres what I have done :
<script>
$(function() {
$('.table').on('swiperight', function(){
$.mobile.changePage("#home");
});
});
</script>
I've referred to the JQuery mobile documentation and to other posts here on the forum but have not been able to resolve this issue. Any ideas?
Heres a fiddle of the project. http://jsfiddle.net/a6TZW/
Upvotes: 2
Views: 6444
Reputation: 31732
You don't need to wrap this event within $function()
as such events are triggered once they occur.
Swipe events:
$(document).on('swiperight','.table', function()
{ $.mobile.changePage("#page2");
});
$(document).on('swipeleft','.table', function()
{ $.mobile.changePage("#page1");
});
Also, you can combine them this way:
$(document).on('swiperight swipeleft','.table', function(event) {
if (event.type == 'swiperight') {
$.mobile.changePage("#page2");
}
if (event.type == 'swipeleft') {
$.mobile.changePage("#page1");
}
});
JSfiddle: Test it here
Upvotes: 3