问题
i have implemented some logic inside
$(document).on('pagebeforeshow', '#mainPage', function(){
}
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;
to manually go back to the previous page.
It only gets executed if you do a refresh or directly go to the page using a href<>
Any sugestions?
cheers
回答1:
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
});
});
来源:https://stackoverflow.com/questions/17700177/jquery-mobile-pagebeforeshow-not-executing-after-pressing-back