locked
Stop Home Page From Refreshing

    Question

  • We have a Javascript app that utilizes WinJS.Navigation.navigate() to navigate the single page application.  When the user clicks a link on the home page to another page, then clicks the back button, the home page does not retain the original state/ data on the page, the page reloads as if the application has been restarted. 

    How do we get the home page to retain its original state?

    Our code is based on the example here:

    http://msdn.microsoft.com/en-US/library/windows/apps/hh452768


    Below is the code we are using.  

    In the home.js file

    (function() {

    "use strict";

        WinJS.UI.Pages.define("/pages/home/home.html", {

            }

        });

    functionlinkClickEventHandler(eventInfo) {

            eventInfo.preventDefault();

            WinJS.Navigation.navigate(link.href);    }

     })();              
    A link on the home page calls the page fragment with the following link and text box field:
    <a
    href="/pages/help/Help.html">Help</a>

    <inputtype="text"id="txtTest"/>

    When the user navigates to the Help page (Help.html), then clicks back, the home page is reloaded, clearing the text box field txtTest. 

            varlink = eventInfo.target;
       ready:  function (element, options) {
               WinJS.Utilities.query("a").listen("click", linkClickEventHandler, false);
    Monday, October 08, 2012 7:29 AM

All replies

  • you may use global variables which can be accessed across pages..... like define and expose the variable using the namespace in your data page (data.js may be...).

    in case if it is not null, set the values....

    other way can be using history.back..... but then, you may be displaying some stale /old data which may not be appropriate


    Arindam Basu

    Friday, November 09, 2012 6:04 AM