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.
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.
-
Hi!
Uhm, Jeff - is it really possible to do that from inside a webview?
I didn't thinkTi.UI
was available there, so i figured you'd have to pass data through an event, no? Please correct me if I'm wrong!