Passing array data to Window
I want to pass an array of data to an other window
My code is:
var w =Titanium.UI.createWindow({title:'ListView',url:'list.js'});
for(i=0;i<5;i++){
w.array[i] = point[i].title;
}
I know how to do this with a single variable but what about an array?
2 Answers
-
I'm pretty sure that setList and getList methods of Ti.APP.Properties is what you're after:
https://developer.appcelerator.com/apidoc/mobile/1.2/Titanium.App.Properties
There's an example in the properties.js file in Kitchen Sink.
Using custom properties when opening the window might also work (not sure, haven't used it much thus far). Might be worth checking out custom_properties.js and custom_properties_2.js in the Kitchen Sink as well.
-
Try this..
In list.js:
Titanium.UI.currentWindow.addEventListener('send_data', myDataFunction); function myDataFunction(e) { Titanium.API.info("Data: " + e.dataArr); };
In app.js:
var data = [1,2,3]; var w = Titanium.UI.createWindow({ title: 'List', url: 'list.js' }); w.open(); w.fireEvent('send_data', {dataArr:data});