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
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..
//Global var AppInit=true; var win ....(etc) win.addEventListener('open',function(e){ if(AppInit){ //populate the window AppInt=!AppInt; } });
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…
-
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.