Hi all. i am currently creating a mobile application using titanium studio. I would like to insert rows and below are my codes but i got an unknown error. After i clicked into button 'Test Apps', it will go to another page with a box. I wanted to display the date in it but nothing is being displayed. and i want to create rows below the box if possible so that i can retrieve my data and display them rows by rows. anyone can help?
function ApplicationWindow(title) { var self = Ti.UI.createWindow({ title:title, backgroundColor:'gray' });
var myDate = new Date(2012,3,29); var myPicker = Ti.UI.createPicker({ type: Ti.UI.PICKER_TYPE_DATE, height: 'auto', width: 'auto', top:'10dp', value: myDate }); var myWin = Ti.UI.createWindow ({//<< create your window outside the listener so you dont end up creating multiple windows every time you click on the button title: L('newWindow'),
backgroundColor: 'white'
}); myWin.add(myPicker) var button = Ti.UI.createButton({ height:44, width:200, title:L('Test Apps'), top:20 }); self.add(button);
var myWinn = Ti.UI.createWindow({ title: L('newWindow'), backgroundColor:'white' });
myWinn.add(table); var tableData = [{title:'A'}, {title:'B'}, {title:'C'}]; var table = Ti.UI.createTableView({ data:tableData }); self.add(table);
button.addEventListener('click', function() { //containingTab attribute must be set by parent tab group on //the window for this work self.containingTab.open(myWin); self.containingTab.open(myWinn); Ti.API.info('Date' + myPicker.value) });
return self; }; module.exports = ApplicationWindow;
1 Answer
You're calling
myWinn.add(table);before you've defined
table. That will likely cause your app to crash before you even see the first window.
Not to mention that you're later adding table to another window. You would be much better off putting each window into its own CommonJS module so that you don't have to reuse variable names like that.
Your Answer
Think you can help? Login to answer this question!