Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Push same pages multiple times to Navigator



  • Here is the case - for simplicity lets say my app consists from 5 pages (real situation is little more complex). Logically they are on one level. User may switch these 5 pages any way he wants and he can open any of these pages more than once. So lets say user opens pages in this order:

    page1 -> page2 -> page4 -> page2 -> page4 -> page2

    Every time I just push the new page in the Navigator, so the pages array becomes larger and larger even there are just 5 pages. The idea behind this is when user presses back button to go back logically in same order as pages were pushed, so show page2 and page4 two times again. The problem is all these pages stay in DOM too (I use React) and potentially DOM may become unnecessarily large. Is there are proper way to solve this issue? Maybe reset Navigator at some point to some reasonable amount of pages in the history? What about DOM?



  • @mishoboss For this specific scenario (and there may be a better method using Onsen), I would just push and pop pages so only one was actually stored. Push the page name to an array, have a backbutton event listener where you can use FILO principle to display the appropriate page.