Return to root tableview on tab click (iPad)
I am building an application that uses a tableview/detailview within a tabgroup. Currently, the app works great except for one issue. When the user navigates to another tab within the tab group (not the one that has the tableview/detailview) when they have the detailview open, then goes back, it brings them back to the detailview they were looking at.
For most applications I understand this is probably the desired behavior, however in my application I want to return them to the "root", which is the tableview.
Is there a way to do this?
2 Answers
-
You want to capture the focus event on the Titanium.UI.TabGroup object.
This code assumes the tableView with detailView is in the first tab, with index 0
When the tab group gets focus, make sure the index is not the same as t previous index and if the index is 0 then do your magic, make sure the view is at the top level and not on the details
tabGroup.addEventListener('focus', function(data) { if ( data.index != data.previousIndex && data.index == 0) { // reset view to initial state } });
-
So far, the best answer I can find for this is in this thread, but it's very hacky.