Closing multiple windows
Hi
On iPhone, I am creating windows in same tab like this
win1 -> win2 -> win3 -> win4
Now I want to call an event from a different tab which should be able to close win4 till win2 leaving only win1 open.
I tried the approach of attaching an event listener in all windows to close them and then called it in it's child's close event, but this leaves me on win2 with no background and navbar showing it's title.
Please help me out in achieving it.
3 Answers
-
I would also like to know how to accomplish this. I guess we need to keep track of win2, win3, etc, but I'm not sure how to do this from window to window. Any help would be appreciated.
-
Hi,
try this
/* * At win1 during win2 creation */ var win1 = Ti.UI.currentWindow; var win2 = Ti.UI.createWin... { //all win props, url:'win2.js', } /* * At win2 during win3 creation */ var win2 = Ti.UI.currentWindow; var win3 = Ti.UI.createWin... { //all win props, url:'win3.js', _win2:win2, // we add win2 to win3 } /* * At win3 during win4 creation */ var win3 = Ti.UI.currentWindow; var win4 = Ti.UI.createWin... { //all win props, url:'win4.js', _win3:win3, // we add win3 to win4 _win2:win3._win2, // we add win2 to win4 } /* * On win4 */ var win4 = Ti.UI.currentWindow; //add an event on win4 Ti.pp.addEventListener('closeAllWin',function({ //we start closing the windows from win2 to win4 and if you try the other way round //this wont work win4._win2.close(); win4._win3.close(); win4.close(); }));
-
Have similar problem; win1 > win2 w/o tabs and want to add event listener in win2 but it doesn't respond ? How does "_win2:win2" work ?