This is the follow-up of my previous thread here: http://developer.appcelerator.com/question/127384/passing-array-to-new-window
I want to pass a variable (an array, in this case) between two *.js files as I need to re-use the information entered by the user. The app does not use a database and it does not need to. I understood from the other thread I should use a JSON stringify approach which I tried without succes.
Here is an example with three files:
init.js
var transferVars = [];01.js
Ti.include('init.js'); transferVars.push({'test': true});02.js
Ti.include('init.js'); var transferredVars = JSON.stringify(transferVars); var testResult = transferredVars['test'] alert(testResult);This gives "undefined" as result... What am I doing wrong?
2 Answers
Accepted Answer
did yout try just firing an event from one file that the other file is listening for? The payload of the event is the array you are passing
Aaron's solution works, but creates another problem in my code which made me use a workaround for now. Should consider using a database in the future, maybe.
Thanks for the help!
Your Answer
Think you can help? Login to answer this question!