Sorry if this has been asked before but I can't find the answer. How would you recommend triggering a page refresh/reload when the back button is clicked. It doesn't look like the page's init is called when it is navigated to from a back button. Should I manipulate the history or something? Any advice would be great. Thanks for the great work.
Right, it doesn't trigger init event again, because the previous page is always sit in dom to keep ability of doing swipe back. So there are few approaches here:
//For example you have navigation Page1 -> Page2 -> Page3.
//And when you back from Page3 to Page2 yo need to refresh Page2.
myApp.onPageBeforeAnimation('page2', function (page){
//right before animation from page3 to page2
if (page.from === 'left') {
//update here page2
}
});
Other approach is you can remove Page 2 from the dom after page3 becomes visible:
myApp.onPageAfterAnimation('page3', function (page){
//Page 3 arrives, we may remove Page 2 from dom and it will
//be reloaded when you click on back link
$$('.page-on-left').remove();
})
You also need to add page2's url to ignoreCache array, so it should be reloaded with updated data with each request
Alright, cool. Thanks for the advice.
Already possible in 0.9.6 by adding data-forceUrl="true" attribute to back link or using goBack with forceUrl/ignoreCache options
This is my code .
myApp.onPageBeforeAnimation('page2', function (page){
if (page.from === 'left') {
page.view.router.refreshPage();
}
});
But page2 cant`t refresh .Why? @nolimits4web
@631068264 I am having this same issue, did this ever get resolved?
Use '' to trigger it for all pages
myApp.onPageAfterAnimation('', function (page){
if (page.from === 'left') {
}
});
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
698 @amaster507 back and refresh