How to clear previous pages from history from the view?


#1

I am trying to remove previous pages from history in some specific cases!

to explain!

I am at the home page and I want to go to check if I have saved some favourites in my favourites page, in that favourites pages I found I have 3 saved favourites and I want to check which ones are, so I check the details by clicking details and I go to a third page.

  1. page home
  2. page saved favourites
  3. page saved favourites details

home -> list of 3 favourites saved -> open details of the 3 saved favourites saved

when I am in the third page I want to be able to return home or go to another page…

if I return home I am using this code below to return back in history to home page:

        var view = app.views.current;
        view.router.back(view.history[0], {
          force: true
        });

but if from favourites I go to another page using:

app.router.navigate("/hotel-list/", {
          context: {},
          force: false,
          ignoreCache: true
        });

then when I go back from this new page “hotel list” page I return to favourites again and I need to return to the page previously to favourites so I need to remove the history pages of favourites in between…

this means I will back to home again not to favourites…

is that possible to clear some previous pages from the history in the view?
thanks


#2

This should work no matter how deep you are and you should be returned to home page


#3

big thanks Vladimir appreciated!!!


#4

It is possible to clear also pages in between from the route?

to tell it simple I need to delete some pages in between so I do not create a loop of pages that link to another page that link back to the same page again…

is that possible?
thanks