Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked April 20th 2010 by teo economou
  • array
0 Comments

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.

    — answered April 21st 2010 by Dan Giulvezan
    permalink
    0 Comments
  • 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});
    
    — answered April 21st 2010 by Markus Bergh
    permalink
    1 Comment
    • If i need to send two arrays ? Sintax?

      — commented July 25th 2011 by Leonardo J. Castillo C
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.