myView.router.back(url) doesn't work

Hi,

I want to back to index page after few pages with using myView.router.back function.

But I can only back to the previous page not the index page.

i’m using routes to change page and using templateUrl for dynamic content.

function for the close button:

$$('.close').on('click', function (){

 mainView.router.back({
 url: ‘./index.html’,
 force: true,
 });

});

Demo link: http://137.189.85.162/ccc+s/app

path: index > urban > any project > click home button > index

Thanks for helping me.

you can do like this

app.router.navigate('/')

Edit:
router.back() works fine, its working as its supposed to
here is the doc of router.back()
Full doc

router.back(url, options) Go back to previous page, going back in View history
url string - url to navigate to (optional).
If not specified, then it will go back to the previous page in history.
If specified and there is previous page in history then it will be ignored.
If specified and there is a force: true option then will remove previous page from DOM and navigate back to the specified page URL
options - object with additional navigation properties (optional):
animate (boolean) - whether the page should be animated or not (overwrites default router settings)
pushState (boolean) - whether the page should be saved in browser state. In case you are using pushState, then you can pass here false to prevent route getting in browser history
ignoreCache (boolean) - If set to true then it will ignore if such URL in cache and reload it using XHR again
force (boolean) - if set to true then it will ignore previous page in history and load specified one

Try it
app.router.back();

Example: app.router.back(url, options)

More infos:
https://framework7.io/docs/view.html#router-api-methods-properties

1 Like