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?
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?
-
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?
-
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' });