Im trying to make this app, and using a for counter loop for adding the data, but I can't get the addEventListener to open up the .js file. The source path is correct. I verified that from properties!
I tried to do it on an alloy project, but failed, so went back to a traditional project
The code for the app.js file is below:
var win = Ti.UI.createWindow({
title: 'Categories',
exitOnClose: true
});
var data = [];
var categories = [
{title:"Art", url:'app://project 333/Resources/art/artCategory.js'},
{title:"Automotive"},
{title:"Books & Literature"},
{title:"Buildings"},
{title:"Business"},
{title:"Dance"},
{title:"Economy"},
{title:"Education"},
{title:"Fashion"},
{title:"Food"},
{title:"Gardening"},
{title:"Hacking"},
{title:"Health"},
{title:"IT"},
{title:"Military Affairs"},
{title:"Mining"},
{title:"Movies"},
{title:"Music"},
{title:"News"},
{title:"Politics"},
{title:"Sports"},
{title:"Travel"}
];
for (i = 0; i <= categories.length - 1; i++){
var row = Ti.UI.createTableViewRow({
url: categories[i].url,
hasChild:true
});
var rowdata = Ti.UI.createLabel({
text: categories[i].title,
color: '#000',
font: { fontSize: 24, fontWeight:'Italics', fontFamily:'Helvatica' },
hasChild:true,
});
row.url = categories[i].url;
row.add(rowdata);
row.categories = categories[i];
data.push(row);
}
var table = Ti.UI.createTableView({});
table.setData(data);
table.addEventListener('click', function(event){
if (event.row.categories.url){
var win1 = Titanium.UI.createWindow({
url: event.row.categories.url,
title: event.row.categories.title,
_parent: Titanium.UI.currentWindow
});
win1.open({
url: event.row.categories.url
});
}
});
win.backgroundColor = 'white';
win.add(table);
win.open();
Here is the file I am trying to open in the new window:
var win1 = Ti.UI.currentWindow({
title: "Category of Art"
});
win1.backgroundColor = 'white';
var categories = [
{title:"Latest Creations", path:"art/latestCreations/londonartguide.js"},
{title:"Tutorials"},
{title:"Artists"},
{title:"Exhibitions"}
];
var data = [];
for (i = 0; i <= categories.length - 1; i++){
var row = Ti.UI.createTableViewRow();
var rowdata = Ti.UI.createLabel({
text: categories[i].title,
color: '#000',
font: { fontSize: 24, fontWeight:'Italics', fontFamily:'Helvatica' },
hasChild:true
});
row.path = categories[i].path;
row.add(rowdata);
row.hasChild = rowdata.hasChild;
data.push(row);
}
var table = Ti.UI.createTableView({});
table.setData(data);
table.addEventListener('click', function(e){
if (e.row.path){
var nextWin = Titanium.UI.createWindow({
path: e.rowData.path,
title: e.rowData.title
});
nextWin.open();
}
});
win1.add(table);
win1.open();
Any kind of help would be highly appreciated. Also, this is for an android app, so the iphone navigation is out of question.