Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked November 5th 2010 by Javier Muniz
  • detailview
  • ios
  • ipad
  • tabgroup
  • tableview
0 Comments

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
        }
    
    });
    
    — answered November 7th 2010 by Aaron Saunders
    permalink
    1 Comment
    • This works for catching the event, but I'm having issues returning to the root view. The way I've implemented the detail is to open a new window. Trying to return to the root view by closing the open "subwindows" causes the app to display an empty window :(

      — commented November 27th 2010 by Javier Muniz
  • So far, the best answer I can find for this is in this thread, but it's very hacky.

    — answered December 26th 2010 by Ted Haeger
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.