Titanium Community Questions & Answer Archive

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

How to redirect to another window programmatically

How do I redirect from one window to another programmatically. The user can use the tabs in the tab group up top for moving between them but at times within javascript I need to redirect the user automatically from one window to another. How do I accomplish this?

— asked November 3rd 2010 by Justin Toth
  • window
0 Comments

3 Answers

  • var new_window = Titanium.UI.createWindow({
      title:"New Window"
    });
    
    new_window.open();
    

    Is that what you mean? I don't quite understand. You could throw that in a setTimeout or an Event?

    — answered November 3rd 2010 by Colton Arabsky
    permalink
    0 Comments
  • Thanks for the reply. That might be what I'm looking for, I'm not sure. I'm basically just looking for a way to navigate between different pages (external javascript files, but I guess technically they're "windows".) With the code above it looks like if I go from page 1 to page 2 then back to page 1 then back to page 2, there will now be 4 windows open. It seems like it should redirect back and forth in the same window. Is that not how it works in Appcelerator?

    — answered November 3rd 2010 by Justin Toth
    permalink
    1 Comment
    • OK it's definitely not what I'm looking for. I have a tab group with the tabs Home, Games, Teams, and Settings. If I go to the Settings tab and then click a button which redirects me to the Teams tab, it shows the Teams view under the Settings tab. If I then go to a different tab like Home and then back to Settings, it still shows the Teams views instead of the Settings view. I'm finding this tabgroup to be quite the pain in Android, you'd think basic navigation would work but it doesn't… :(

      — commented November 3rd 2010 by Justin Toth
  • The answer ended up being using events to access the tabgroup in app.js from the windows:

    app.js:

    Titanium.App.addEventListener('switchTab', function (e) {
            switch (e.tab) {
                case 'home': tabGroup.setActiveTab(tab1); 
                    break
                case 'scores': tabGroup.setActiveTab(tab2); 
                    break;
                case 'teams': tabGroup.setActiveTab(tab3); 
                    break;
                case 'settings': tabGroup.setActiveTab(tab4); 
                    break;
            }
        });
    

    to trigger the navigation change in some external js file (window):

    Titanium.App.fireEvent('switchTab', { tab: 'teams' });
    
    — answered November 4th 2010 by Justin Toth
    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.