Titanium Community Questions & Answer Archive

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

Navigation Tips/Advice (Reopening windows)

Hi there,

I'm creating an app which will have a menu screen with a number of buttons on which will then load individual games when pressing one of the buttons.

What I want to do is have the main menu in a window and each button then opens up a game in a new window so I can then have the code/logic in a separate js file.

The only issue with this is if I close the game window to return back to the main menu, and I re-open the same window again, the contents of the window are duplicated (due to the window.open() function being called again).

Can anyone advise how they go about re-opening windows so that they don't get the duplicate content issue? Is it just as simple as removing all the content when the window.close() function is called (this would be a bit of a nightmare as I have a lot of content in there).

I suppose I can use views but I really wanted to separate the code for each game/window into it's own js file.

Hope someone can help.

Kind regards

Paul Pounder

— asked November 21st 2010 by Paul Pounder
  • close
  • navigation
  • open
  • reopen
  • view
  • window

2 Answers

  • Accepted Answer

    hi Paul

    Aaron's idea would do a great deal…. just maintain a boolean var to see if the window was opened earlier..

    var AppInit=true;
    var win ....(etc)
          //populate the window

    other work around is if you are targeting iPhone then try using Navgroup or if its Android try using Modal window and don close the Main window…

    — answered November 22nd 2010 by Satta Ravi
  • you can have an event listener for the window open event that would determine if the window has been opened before or not and in there take the appropriate actions.

    — answered November 22nd 2010 by Aaron Saunders
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.