Framework7: Reload/Init Page on Back Clicked

Created on 19 Aug 2014  路  9Comments  路  Source: framework7io/framework7

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.

outdated

Most helpful comment

698 @amaster507 back and refresh

All 9 comments

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?

698 @amaster507 back and refresh

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wakiem picture wakiem  路  4Comments

seme1 picture seme1  路  5Comments

vousys picture vousys  路  4Comments

M4ttscx picture M4ttscx  路  4Comments

mesutgok picture mesutgok  路  4Comments