passing an object from one window to another

You must Login before you can answer or comment on any questions.

hi

is it possible to pass an object say a button from one window to another

— asked 10 months ago by Napp Dev
0 Comments

3 Answers

Accepted Answer

You can pass the object between windows using three methods,

  • App Properties
  • Window Parameter
  • FireEvents

1)App Properties already explained by Abdul Sattar

2)Window Parameter

in your current window
 
var win1 = Ti.UI.createWindow({
    url = "win1.js",
    customValue:"yourCusomValue"
});
 
in win1.js 
 
var win = Ti.UI.currentWindow;
var myCustomValue = win.customValue;
3)FireEvents

in your current window

Ti.App.fireEvent('sync', {name:'customValue'});
in new window
Ti.App.addEventListener('sync', function(data) 
{ 
     var myCustomValue = data.name; 
});

Hello Nap,

you can also do it with the declare it global

like

Ti.App.mybutton = buttomname;

and you can fetch it in any window of your project like

var mybutton = Ti.App.mybutton;.

yes. you can set that object to string like

Ti.App.Properties.setString('button1', button1_value);
and you can get this in any window in the same App like
var btn_got=Ti.App.Properties.getString('button1', null);

Your Answer

Think you can help? Login to answer this question!