jQuery Mobile Swipeleft/Swiperight issue

I’m implementing a swipe left/swipe right to the mobile photo gallery so phone users can swipe between photos. It works as expected but only once. So if I swipe left or right I go to the next or previous image but then it no longer works.

<script>
<? if ($prev != '') { ?>

$(function(){
$("#home").bind('swiperight',function(event, ui){
$.mobile.changePage("/photo.php?id=<?=$prev?>&album=<?=$album?>", "slide");
});
});

<? } if ($next != '') { ?>
$(function(){
$("#home").bind('swipeleft',function(event, ui){
$.mobile.changePage("/photo.php?id=<?=$next?>&album=<?=$album?>", "slide");
});
});
<? } ?>
        </script>

Help? :slight_smile:

I’m new to jQuery but the problem seems to be…

Lets say you have 3 photos. We start at picture 2. Swiping left would lead to picture 3… once at picture 3 you would think swiping right would put you back at picture 2 but instead it has that swipe event stored as picture 1. I’m hoping someone knows how to reset these swipes on each page load to the newly presented information.

Thanks :slight_smile:

Issues with swiping on mobile devices seem to be neatly resolved when using this swipe library