我正在用这种方法更改页面
$.mobile.changePage("Preview.html", {
transition : "slide",
role : "page",
changeHash:true
});
这就是我的预览页面的样子
<div data-role="page" data-name="preview" class="prew">
<div data-role="content">
//content
</div>
</div>
现在,当我触摸屏幕时,我必须返回到上一页。
所以我创建了这个函数
$('.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" 在其他页面上工作正常。
photoswipe 阻止返回上一页。
这是您可以使用的方法。然而,页面应该有一个唯一的 ID 才能使其正常工作。
在这里测试一下 http://jsfiddle.net/Palestinian/Uqvns/.
$('.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
});
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)