I have 4 views all with a single button. I want the following simple behaviour.
- home: Clicking the button should go to dashboard. Clicking the Android back button should exit the application
- dashboard: Clicking the button should open profile. Clicking the Android back button should close the current window and return back to home.
- profile: Clicking the button should open settings. Clicking the Android back button should close the current window and return back to dashboard.
- settings: Clicking the button should close the settings, dashboard and profile pages and return the user back to home. Clicking the Android back button should close only the current window and return back to profile.
This is what I have so far:
home
<Alloy>
<Window class="container">
<Button onClick="openProfile">Open Dashboard</Button>
</Window>
</Alloy>
With JS:
function openDashboard() {
Alloy.createController('dashboard').getView();
}
dashboard
<Alloy>
<Window class="container">
<Button onClick="openProfile">Open Profile</Button>
</Window>
</Alloy>
With JS:
function openProfile() {
Alloy.createController('profile').getView();
}
profile
<Alloy>
<Window class="container">
<Button onClick="openSettings">Open Settings</Button>
</Window>
</Alloy>
With JS:
function openSettings() {
Alloy.createController('settings').getView();
}
settings
<Alloy>
<Window class="container">
<Button onClick="backToHome">Back To Home</Button>
</Window>
</Alloy>
However I am unsure on the JS to use to close both parent windows.