按下后不执行jQuery Mobile"pagebeforeshow" [英] Jquery mobile ''pagebeforeshow' not executing after pressing back
本文介绍了按下后不执行jQuery Mobile"pagebeforeshow"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在内部实现了一些逻辑
i have implemented some logic inside
$(document).on('pagebeforeshow', '#mainPage', function(){
}
但是当用户eitehr按下返回键返回到包含此JS的特定页面时或调用时,它不会加载
but it doesnt load when a user eitehr presses the back key to go back to this specific page containg this JS or when calling
history.back(-1); return false;
以手动返回上一页.
仅当您刷新或使用href<>
It only gets executed if you do a refresh or directly go to the page using a href<>
有没有建议?
欢呼
推荐答案
由于您使用的是多文件模板,因此您需要从历史记录document.referrer
中获取以前的URL.
Since you're using multi-files template, you need to fetch previous URL from history document.referrer
.
Demo
$('.selector').on('click', function (e) {
e.preventDefault();
var page = document.referrer;
$.mobile.changePage(page, {
transition: 'flip',
reloadPage: true, // optional, force page reload.
reverse: true
});
});
这篇关于按下后不执行jQuery Mobile"pagebeforeshow"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文