Titanium Community Questions & Answer Archive

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

Change tab

I know using setActiveTab will change it, but what if my tabGroup lives in app.js and I am in a window called create.js and want to change the tab? Is their like a parent method?

— asked October 12th 2010 by Ronnie Swietek
  • change
  • parent
  • tab
0 Comments

3 Answers

  • Like so:

    var tabGroup = Ti.UI.currentWindow.tabGroup;
    
    //assuming 1 corresponds to the tab you want to switch to
    tabGroup.setActiveTab(1);
    
    — answered October 12th 2010 by Mike Dosey
    permalink
    1 Comment
    • Thanks… this was driving me nuts I forget the scope of the tabGroup was definied in app.js not in the current js file..

      — commented February 21st 2011 by Michele Hjorleifsson
  • Hmm, I haven't done this in my own code, but you could store the tabs as properties of the tabGroup object, so they become accessible to any window.

    var myTab= Ti.UI.createTab({...});
    tabGroup.myTab = myTab;
    ...in some other file...
    var tabGroup = Ti.UI.currentWindow.tabGroup;
    tabGroup.setActiveTab(tabGroup.myTab);
    

    Maybe there's a better way, though.

    — answered October 12th 2010 by Mike Dosey
    permalink
    0 Comments
  • Ok that works. How can I pass the object rather than a number? I'd rather call it by the name. tabGroup.setActiveTab(tabName);

    — answered October 12th 2010 by Ronnie Swietek
    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.