Passing parameters to window in Titanium appcelerator

Titanium is a JavaScript based framework, which encapsulates the native APIs and exposes them using JavaScript interfaces.

to open a new window in Titanium.

var win = Ti.UI.createWindow({
    id:'window',
    url : '/newwindow.js'
});

suppose now we want to pass some parameter to this window and access those parameters in the new window newwindow.js JavaScript file.

Here we are using Javascript so we can always pass parameters using the properties, like.

var win = Ti.UI.createWindow({
    id:'window',
    url : '/newwindow.js',
    parameter1 : 'value1',
    parameter2 : 'value2'
});

Now to access these values in the new window, here is the code of the newwindow.js.

var win = Ti.UI.currentWindow;
win.parameter1; //value of parameter 1
win.parameter2; //value of parameter 2
Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*