Going back to previous page works in simulator not on iOS device jquerymobile

cordova, jquery-mobile, photoswipe

Solution

Here is a method you could use. However, pages should have a unique ID in order to have this working.

Test it here.

$('.prew').on('tap', function() {

 // get the ID of the previous page
 var previous = '#' + $.mobile.activePage.prev('div[data-role="page"]')[0].id;

 // move to previous page with reverse effect
 $.mobile.changePage(previous, {
    transition: 'slide',
    reverse: true
 });
});

Problem

I am changing the page with this method ``` $.mobile.changePage("Preview.html", { transition : "slide", role : "page", changeHash:true }); ``` this is how my preview page looks like ``` <div data-role="page" data-name="preview" class="prew"> <div data-role="content"> //content </div> </div> ``` now when i touch the screen i have to go back to previous page. so i created this function ``` $('.prew').live('tap', function() { alert('clicked'); history.go(-1);//<--this works in simulator not in device. //window.history.back() ;//<--this also works in simulator not on device. //navigator.app.backHistory();<--this works fine on android not on iOS. }); ``` edit: i have used a plugin called photoswipe which causes the issue . the history.go(-1),history.back() or data-rel="back" works fine on other pages. photoswipe is preventing from getting back to previous page.

Original source