Navigation: how to return to home?
Hi guys, I'm in trouble with my app.
I have a single window with a dashboard. When I click on a icon I open a new window. Then another child win etc…
At the beginning I made a Navigation Group without Tabs Group as you can see on Developer Blog. The problem was to create and add dynamic children to the window.
So I made a tabgroup with a single tab and hidden tabbar. It's cool because I can use Titanium.UI.currentTab.open to add a child.
It's also a cool thing that, if you click on the tab button, you return to the "root" window. It's very usefull if you have a lot of children..
How can I simulate this behaviour? I added a button to the navbar of every window.. I would like that, when a user click this button, the app returns to the main tab window (same behaviour as tab button click).
Thanks a lot! Have a nice day,
Flavio
4 Answers
-
For tabgroups. I saved the tabgroup object back onto the Ti.UI object for later usage. When I want to switch tabs and go back to the home/root/initial window of the tab, I found the simplest way was to just close and reopen the tab group with activeTab set to the index you wanted. It's cheesy but seems to work. I would think the same method would work for navgroups as well.
In the app.js file:
// created an object called tabGroup that has already // been setup with all my tabs Ti.UI.tabGroup = tabGroup;
In another js file for a tab:
add_button.addEventListener('click',function(){ Ti.UI.tabGroup.setActiveTab(1); Ti.UI.tabGroup.close(); Ti.UI.tabGroup.open(); });
It works better than I thought it would actually. My screen doesn't seem to show the fact I just closed and opened the tabgroup.
-
I am having exactly the same issue, although I am switching from a different tab. The switch via setActiveTab is fine but … on a button click I want to send the user back to the first window in the drill. I too am using a tabgroup, which simulates the effect perfectly, if you click on the tabgroup button at the bottom of the app.
Is there a fireEvent that can take place? I am already using setActiveTab() but that takes me to the drill at the level it was left.
Thanks,
Tim..
-
My workaround for this problem when using a navigation group was simply re-open the root window for the nav group (and close the old one).
-
What I do was let the main Window into a function, so when the user click on "Home" button, i just call home() function.