Titanium Community Questions & Answer Archive

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

activeTab shows nothing

Hello. If the TabGroup has more than 5 tabs and if you set tabGroup.activeTab = tabGroup.tabs[5]; for example, this will open just blank tab, it doesn't fire any 'focus' event, nothing, looks like it opens only tab without window inside, but if you set active tab less than 5, it will show it perfectly

— asked April 16th 2010 by Vitali Virulaine
  • tabgroup
0 Comments

5 Answers

  • Just ran into this. It seems like the TabGroup is basically deciding not to 'open' more windows than the visible tabs, so your .js doesn't get executed. The setActiveTab doesn't seem to be aware of this in the same way as when you click on a tab which 'opens' the window.

    2 workarounds

    #1

    I only have 1 tab that I need access to programmatically that lives beyond the visible 5 tabs by default. So in app.js I do a win10.open(). That runs the code and now the focus event is in place for the setActiveTab() to work properly. I'm sure there is a more elegant solution, but I haven't explored further. fwiw

    #2 (to maintain lazy loading)
    For any window outside the visible 5… In app.js add something like…

    tabGroup.addEventListener ('focus', function(e){
    if(e.index == 7) {
    if(!win7.didRun) { win7.open(); }
    }});

    In the creation of the window in the app.js make a variable like 'didRun:false'

    At the end of the window code, such as in the example above win7.js just set the variable didRun=true;

    There is probably a variable we could look at in the window structure to know if the code was run… but I've got other things to fix. :)

    — answered March 30th 2011 by Steven Day
    permalink
    2 Comments
    • Looks like when you tap on 'More', that is when the code for those windows is loaded.

      — commented March 30th 2011 by Steven Day
    • The second workaround works great. Thanks!

      — commented May 15th 2011 by Jose R Castello
  • hey buddy can you be a bit clear…how many tabs do you really have and what error you face while referring to which tab

    — answered April 17th 2010 by Satta Ravi
    permalink
    0 Comments
  • I have 7 tabs and I get no error, just opened tab with black inside. It is weird that there is no even Focus event fired. So.. if i set active tab 1,2,3,4 it works great, if i set it to the tab witch is hidden in More option - I get just blank tab

    — answered April 18th 2010 by Vitali Virulaine
    permalink
    0 Comments
  • The same thing is happening to me. The visible tabs (1-4) work but the ones hidden under the MORE option does not.

    — answered July 14th 2010 by Antonio Tangarife
    permalink
    0 Comments
  • Nearly one year later and I'm having exactly the same problem.
    It seems this is not solved yet.

    The window code never gets executed when I try to programatically access a tab>5. Thus a black window (no content is generated).

    I does work if I manually accessed the tab earlier on, as this generates the content i.e. executes the window code.

    Any solutions/workarounds?

    — answered January 27th 2011 by Friedrich Seydel
    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.