回到上一页在模拟器不工作在iOS设备jquerymobile [英] Going back to previous page works in simulator not on iOS device jquerymobile

查看:125
本文介绍了回到上一页在模拟器不工作在iOS设备jquerymobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此方法更改页面

$.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.

所以我创建了此功能。

$('.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.
    });

编辑:
我使用了一个名为photoswipe的插件,导致问题。 history.go(-1),history.back()或data-rel =back在其他网页上正常工作。

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无法恢复

photoswipe is preventing from getting back to previous page.

推荐答案

这里是一个可以使用的方法。但是,网页应该有一个唯一的ID,以使其工作。

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

在此测试

$('.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
 });
});

这篇关于回到上一页在模拟器不工作在iOS设备jquerymobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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