Router: close all pages and navigate to route

sorry for my English, as it is not my mother tongue.

I am having problems with router component:

Is there a way to navigate to a new route closing all open pages but the first?

I mean, if I have a strack of pages, like:

  • home page -> sheet 1 -> sheet 2 -> sheet 3

from a button in sheet 3 i want to transition to this state:

  • home-page -> sheet X.

app.views.main.router.navigate(newroute, {clearPreviousHistory:true});

closes all previous pages, including home page. Sheet X is displayed, but i can’t go back to home.

I have tried other approaches, like that:

app.views.main.router.navigate('/', {force:true}); app.views.main.router.navigate(newroute, {force:true});

but this way, app remains in the home page. I guess it is a synch issue (I am navigating to newroute when the navigation to ‘/’ is not complete).

Thanks in advance, i would appreciate any help!

hi, i dont think there is a clean way of achieving what you want. or i don’t know it. You can look in the router history and remove the unwanted routes after you enter sheet x.
this dosnt work bcs, as you guess correcty f7 has a prop in router

router.allowPageChange // Boolean property indicating is it allowed to change page / navigate or not

allowPageChange will be false until the router finish it navigation. so to use that aproach you have to use event listeners and listen, after the page loads you can the navigate again.

maybe nolimits has a better solution than popping the unwanted routes from history

Thanks for the response.
Currently I am solving it with a timeout, but that prop, allowPageChange, can help :slight_smile: