[BUG] Android - Passing Data
Hi,
there is a section about passing data between windows in the documentation. This technique does not work for Android, I get this Runtime Error:
TypeError: Cannot call property testFn in object
ti.modules.titanium.ui.WindowProxy@43e99d18.
It is not a function, it is "object".
Is there any solution for this problem?
Does accelerator team know about this bug?
(I could not find any ticket which refers to this problem)
Thanks in advance for your help.
2 Answers
-
Accepted Answer
Thanks for bringing this back to our attention. I've added Ticket 882 for tracking.
-
I have also had this issue. My workaround is to create the functions in another helper .js file that I included on every page.
ex:
var myData = Ti.UI.currentWindow.myData
myData.setX = function(x) {this.x = x};
I would also like to add that there is a another problem passing data this way to windows. The passed data is not copied via reference so the changes made to the object by the calling window are not available to the caller. currentWindow seems to create a COPY of the object and returns that. A good example:
var myData = {x:0}
var win = Titanium.UI.createWindow({ url: 'window2.js', myData: myData });
win.open();
//then in the calling window:
Ti.UI.currentWindow.myData.x = 1
//This will return 0 still even though we just changed it to 1
Ti.API.info(Ti.UI.currentWindow.myData.x)