locked
buttons not working after reloading main menu

    Question

  • My app consists of 3 HTML pages (default.html, game.html, and gameOver.html) and a few javascript/css files.  All of the navigation is done with window.location redirects.  It works great until you reach gameOver.html for the first time and then try to redirect back to default.html if the player wants to play again but choose a different game mode.  It redirects back, but now the buttons on the main menu don't do anything when you click them.  This was pretty much one of my first attempts at Javascript but I'm a CS major so I have some coding under my belt and things aren't really adding up..  Is this a windows 8 lifecycle issue or something?

    Thanks for your help!

    Sunday, October 21, 2012 8:35 AM

Answers

  • Hi stiggybr0,

    When doing UI navigation in windows store javascript applications, we'd recommend that we use the built-in navigation APIs (under WinJS.Navigation ) to switch between our application's UI elements. Just like when the app starts, it needs to call WinJS.UI.ProcessAll to perform some initiaization works for all the WinJS controls, if we directly use the window.location javascript api to navigate between pages(which is commonly used in webbrowser based web apps), it is possible that we've bypassed some necessary processing of the winJS runtime.

    #Supporting navigation (Windows Store apps using JavaScript and HTML)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh452761.aspx

    #WinJS.Navigation Namespace
    http://msdn.microsoft.com/en-us/library/windows/apps/br229778.aspx

    Also, for event handlers in javascript based windows store applications, we also need to make sure we've used the suggested means to bind them to the target element/control.

    #Quickstart: adding HTML controls and handling events (Windows Store apps using JavaScript and HTML)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh465402.aspx

    #How to set event handlers declaratively
    http://msdn.microsoft.com/en-us/library/windows/apps/jj585524.aspx

    Here is the reference page which talks other things about html/javascript programming and difference between windows store and standard webbrowser based pages:

    #HTML, CSS, and JavaScript features and differences (Windows Store apps)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!


    Monday, October 22, 2012 2:53 AM
    Moderator

All replies

  • Are there any errors or warnings written out to the Javascript Console when you are debugging the app?

    Dave Paquette @Dave_Paquette www.davepaquette.com

    Sunday, October 21, 2012 5:41 PM
  • 0 errors 0 warnings =/
    Sunday, October 21, 2012 6:44 PM
  • for anyone else having similar issues, I think using multiple page navigation is the problem.  Windows 8 prefers single page navigation.  I can't post links here but search single page navigation windows 8 and you should get a good article explaining it .  I'm going to try to change to this model tonight and see if it fixes my problem.
    Sunday, October 21, 2012 11:29 PM
  • Hi stiggybr0,

    When doing UI navigation in windows store javascript applications, we'd recommend that we use the built-in navigation APIs (under WinJS.Navigation ) to switch between our application's UI elements. Just like when the app starts, it needs to call WinJS.UI.ProcessAll to perform some initiaization works for all the WinJS controls, if we directly use the window.location javascript api to navigate between pages(which is commonly used in webbrowser based web apps), it is possible that we've bypassed some necessary processing of the winJS runtime.

    #Supporting navigation (Windows Store apps using JavaScript and HTML)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh452761.aspx

    #WinJS.Navigation Namespace
    http://msdn.microsoft.com/en-us/library/windows/apps/br229778.aspx

    Also, for event handlers in javascript based windows store applications, we also need to make sure we've used the suggested means to bind them to the target element/control.

    #Quickstart: adding HTML controls and handling events (Windows Store apps using JavaScript and HTML)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh465402.aspx

    #How to set event handlers declaratively
    http://msdn.microsoft.com/en-us/library/windows/apps/jj585524.aspx

    Here is the reference page which talks other things about html/javascript programming and difference between windows store and standard webbrowser based pages:

    #HTML, CSS, and JavaScript features and differences (Windows Store apps)
    http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!


    Monday, October 22, 2012 2:53 AM
    Moderator