Search code examples
iphonemobiletitaniumappcelerator-mobile

Breaking from default behavior of TabGroups and new windows


Typically, opening a window in a tab is pretty straighforward

Ti.UI.currentTab.open( 
    Ti.UI.createWindow( {url: 'foo.js'} )
  , {animated: true }
);

However, this initiates the "navigation group" style of UI breadcrumbs. A "back" button is automatically placed on the nav bar.

Is there any way to open a window, in the current tab, but start from a fresh history? Or make a "lateral" move to a new window - essentially replacing the current?

To make sure I'm clear, consider this window hierarchy

     root
    /    \
 child1  child2
        /      \
   child3      child4

In each case, a specific user action will open one of two windows into the current tab.

What if I wanted for a button click on child3 to open child4 while respecting the above view heirachy? I wouldn't want "back" to go to child3, I'd want it to go to child2. Like this

     root
    /    \
 child1  child2
        /      \
   child3----> child4

Or what if I wanted "back" to just be gone, effectively starting a new navigation history?


Solution

  • I think you can accomplish the "lateral" move by doing a non-animated close, followed by an open:

    Ti.UI.currentTab.close( 
        child3
      , { animated: false }
    );
    
    Ti.UI.currentTab.open( 
        child4
      , { animated: true }
    );
    

    However, I do not think you can do this on the root window in order to start from a "fresh history".