Reputation: 12549
In Titanium JS, I'm using the newer NavigationWindow component, and you can traverse several windows down into a navigation tree, creating a series of back buttons as you go.
However, I also have a side revealing menu with a "home" option. I'd like this button to take you back to the root window in the NavigationWindow.
Here is a simple example. Imagine that the new window being created could happen several times and you could be several windows into the navigation tree.
In my view
<Alloy>
<NavigationWindow id="navWin" class="container">
<Window title="Window 1">
<Button onClick="newWindow" title="Go to new window" />
</Window>
</NavigationWindow>
</Alloy>
And in my controller:
function newWindow() {
var newWin = Ti.UI.createWindow({ title: "Window 2" });
var goBackBtn = Ti.UI.createButton({ title: "Go to root" });
newWin.add(goBackBtn);
goBackBtn.addEventListener("click", function () {
// goes back to the root window no matter how deep into the navigation tree you are
});
$.navWin.openWindow(newWin); }
$.navWin.open();
Upvotes: 1
Views: 871
Reputation: 1482
Use navAlloy controller for coming to home window
https://github.com/vuinguyen/NavControlTi32
Thanks
Upvotes: 1