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 objects to other windows?

Is there anyway to pass objects to other windows? It would be nice to pass around data arrays and update them when the user initiates an action. If this is not possible can you recommend a good way to store data in the application wide scope? Thanks.

— asked March 10th 2010 by Alex Wolfe
  • array
  • data
  • javascript objects
  • windows
0 Comments

2 Answers

  • You can give access to other contexts via assignment. An example best illustrates this:

    var foo = '1';
    var webview = Ti.UI.createWebView({url:'foo.js'});
    webview.foo = foo;
    window.add(webview);
    

    In the above, the foo variable is assigned to the webview instance. Now, inside the webview you can reference it.

    alert(Ti.UI.currentWindow.foo);
    

    Any changes made to the variable will affect the others since they are live references.

    — answered March 10th 2010 by Jeff Haynie
    permalink
    0 Comments
  • Hi!
    Uhm, Jeff - is it really possible to do that from inside a webview?
    I didn't think Ti.UI was available there, so i figured you'd have to pass data through an event, no? Please correct me if I'm wrong!

    — answered March 21st 2010 by Jacob Waller
    permalink
    0 Comments
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.