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.
How to set <ons-tab> active=false when using pushPage
-
Hello, any suggestion to set <ons-tab> active=false when we use navigator to push new page. Otherwise, when we change tab and come back to the old tab, the old tab will show the popup page instead of original page tab.
-
@iriekun I am a bit confused by what you want. Do you have a navigator in a tab or is the tab in the navigator? Also, do you have it on show of the tab to do the popup? If so, why not wrap that in an if and check a flag?
-
@munsterlander sorry if i didn’t describe clearly. What I want to do is for example Home tab show page 1 and I use navigator pushPage to show page 2(all tabs are shown and Home tab is active)
When I go to Setting tab and click on Home tab again, page 2 is shown instead of page 1(original home tab). So how can I set tab active=false when i push new page?
-
@iriekun Oh ok, so one last question, do you just want to remove any pages pushed to your navigator when you switch tabs so the home page is always set at page 1 OR do you want it where once you change tabs to settings, you can’t click on the home tab at all (because the onsen active does not do that)?
For option 1, I would do this (your home tab should have an ID of home for this example) :
document.addEventListener("show",function(e){ if(e.target.id == 'home'){ // instead of resetToPage this could be a popPage document.getElementById('myNavigator').resetToPage('home'); } });
https://onsen.io/v2/docs/js/ons-navigator.html
http://tutorial.onsen.io/?framework=vanilla&category=Reference&module=navigator