locked
On back navigation the css of the previous page dosn't works. RRS feed

  • Question

  • i am working on navigation template and my forward navigation is working fine but when i navigate back the page loads but the styling changes and the page doesn't loads properly. 

    I am using this code:

    (JAVASCRIPT)

     WinJS.Utilities.query("findfoodbtn").listen("click", linkClickEventHandler, false);

     

      function linkClickEventHandler(eventInfo) {

            eventInfo.preventDefault();
            var link = eventInfo.target;
            WinJS.Navigation.navigate("/listofrestaurants/main.html");
        }

    Kindly review this and tell me how to correct my back navigation in the app.


    deepanshu jaiswal monocept

    Wednesday, January 2, 2013 8:40 AM

Answers

  • Hi,

    Am I right that you are changing stuff in the style sheet on the second page before you use the back button? I think so because you state that 'the styling changes and the page doesn't loads properly'. Those changes will probably not be displayed because the style sheet was cached. A popular way of "cache-breaking" is to append a parameter to your css source.

    Something like this:

    <link rel="stylesheet" type="text/css" href="cssfile.css?t=<%= DateTime.Now.Ticks %>" media="screen" />
    

    Hope this helps

    Please mark the best replies as answers
    Blog: bloggingabout.net/blogs/rick
    Twitter: @rickvdbosch

    • Marked as answer by roadie1000 Wednesday, January 2, 2013 12:51 PM
    Wednesday, January 2, 2013 9:14 AM
  • Maybe you have defined some classes on a page specific CSS file instead of the global default.css file.

    When you create a Page Control, VS creates a .CSS file for the page, any class or rule you define there works for that page only, if you reference any class or rule from other page, they won't work.

    What I do is, if I have an App wide class or rule I want applied to all the pages, I put it in the "default.css" file, if there is a particular class / object that requires a particular style or override for a page, I put it in that page's CSS file.

    • Marked as answer by roadie1000 Wednesday, January 2, 2013 12:51 PM
    Wednesday, January 2, 2013 12:43 PM

All replies

  • Hi,

    Am I right that you are changing stuff in the style sheet on the second page before you use the back button? I think so because you state that 'the styling changes and the page doesn't loads properly'. Those changes will probably not be displayed because the style sheet was cached. A popular way of "cache-breaking" is to append a parameter to your css source.

    Something like this:

    <link rel="stylesheet" type="text/css" href="cssfile.css?t=<%= DateTime.Now.Ticks %>" media="screen" />
    

    Hope this helps

    Please mark the best replies as answers
    Blog: bloggingabout.net/blogs/rick
    Twitter: @rickvdbosch

    • Marked as answer by roadie1000 Wednesday, January 2, 2013 12:51 PM
    Wednesday, January 2, 2013 9:14 AM
  • Maybe you have defined some classes on a page specific CSS file instead of the global default.css file.

    When you create a Page Control, VS creates a .CSS file for the page, any class or rule you define there works for that page only, if you reference any class or rule from other page, they won't work.

    What I do is, if I have an App wide class or rule I want applied to all the pages, I put it in the "default.css" file, if there is a particular class / object that requires a particular style or override for a page, I put it in that page's CSS file.

    • Marked as answer by roadie1000 Wednesday, January 2, 2013 12:51 PM
    Wednesday, January 2, 2013 12:43 PM