Titanium Community Questions & Answer Archive

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

How to pass parameters from one .js file to another?

Hi Friends,

I am very happy that all my questions are answered swiftly. I have a doubt regarding passing parameters from one js to another.

That is, when I create a new window from a js to and open that window, I wanted some data to be passed on to the other js. In objective C, when I create a new ViewCOntroller, I write a custom init function , with which I get the data to intialize the ViewCOntroller. But how can I do here?

— asked July 15th 2010 by Radhakrishnan Selvaraj
  • data
  • passing

1 Answer

  • Accepted Answer

    something like this should do it.

    var variableToSend = 'hello!';
    var newWin = Ti.UI.createWindow({url:'window.js'});
    newWin.variableReceived = variableToSend;

    and then in 'window.js'

    var win = Ti.UI.currentWindow;

    should print 'hello!' in the console when the new window opens :)

    — answered July 15th 2010 by Steve Burtenshaw
    • Hi Steve,

      That worked . Thanks for the help. I was searching for this option for over many days…:)

      — commented July 15th 2010 by Radhakrishnan Selvaraj
    • what about grabbing a value from a modal window and returning it to the calling window? how would that work?

      — commented August 16th 2011 by Michael Stelly
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.