Skip to content

Instantly share code, notes, and snippets.

@minhnc
Created April 15, 2012 08:31
Show Gist options
  • Save minhnc/2390969 to your computer and use it in GitHub Desktop.
Save minhnc/2390969 to your computer and use it in GitHub Desktop.
Navigation Group
var rows = [];
for( var i = 0; i < 30; i++ ) {
var row = Ti.UI.createTableViewRow({
title: 'Row ' + i,
recordID: i
});
rows.push(row);
}
var table = Ti.UI.createTableView({
data: rows
});
var rootWindow = Titanium.UI.createWindow({backgroundColor : "blue", title : "Summary Window"});
rootWindow.add(table);
var nav = Titanium.UI.iPhone.createNavigationGroup({
window : rootWindow
});
var win = Titanium.UI.createWindow();
win.add(nav);
win.open();
var detailWin = null;
table.addEventListener('click', function(e){
var recordID = e.row.recordID;
// TODO - Fetch record based on recordID
// Close previous window
if (detailWin) {
nav.close(detailWin);
detailWin = null;
}
detailWin = Titanium.UI.createWindow({backgroundColor : "white", title : "Detail Window"});
var label = Ti.UI.createLabel({text: 'Detail: ' + recordID, height: 100, width: '100%', color: 'red'});
detailWin.add(label);
nav.open(detailWin, {animated : true});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment