locked
Loading resources for sub-pages in a single page nav app

    Question

  • Hello, I have set up a project to use single page navigation by following this article: http://msdn.microsoft.com/en-us/library/windows/apps/hh452768#step_4__use_the_navigate_function_to_move_between_pages

    I also updated the sub-pages to use localized resources. I have set up a top appbar in default.html that navigates between the sub-pages. However, when those pages are loaded into the window, their localized strings are not displayed. I had assumed that I simply needed to add a call to WinJS.Resources.processAll() into the sub-pages' accompanying JavaScript file. However, when I put a breakpoint into one of those files, I see that the script is never hit during the page navigation. I also tried to directly reference the function in the head of a sub-page; that also did not work.

    Is there an article that shows how to use localized resources with a single page model (loading resources for sub-pages, specifically)?

    Sunday, July 29, 2012 8:46 PM

Answers

  • Thank you, Ming. I just want to reply back in case this helps someone else in the future. I found that the way that I was calling WinJS.Navigation.navigate was preventing the resources from being loaded. 

    Here is what I originally used:

    <div id="divName" class="blah" onclick="WinJS.Navigation.navigate('ms-appx:///html/pages/myPage.html')">
                    Text here
    </div>

    Here is what I changed it to:

    <div id="divName" class="blah" onclick="WinJS.Navigation.navigate('/html/pages/myPage.html')">

    Text here

    </div>

    Note that I also found that one of my page control .js files was missing its page definition. The other four were fine.

    WinJS.UI.Pages.define("/html/pages/myPage.html", {
            ready: ready,
            updateLayout: updateLayout
        });

    Wednesday, August 01, 2012 4:01 AM

All replies

  • Hi,

    When a break point is not hit, either an error occurs before the code has a chance to execute, or the code is not loaded at all. Please check if you referenced the required js file in html, please also check whether something go wrong before WinJS.Resources.processAll. If the issue cannot be found out after checking, it would be better if you can share your demo project via SkyDrive, then we can find the issue more conveniently and provide further suggestions for you.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Monday, July 30, 2012 3:29 PM
    Moderator
  • Thank you, Ming. I just want to reply back in case this helps someone else in the future. I found that the way that I was calling WinJS.Navigation.navigate was preventing the resources from being loaded. 

    Here is what I originally used:

    <div id="divName" class="blah" onclick="WinJS.Navigation.navigate('ms-appx:///html/pages/myPage.html')">
                    Text here
    </div>

    Here is what I changed it to:

    <div id="divName" class="blah" onclick="WinJS.Navigation.navigate('/html/pages/myPage.html')">

    Text here

    </div>

    Note that I also found that one of my page control .js files was missing its page definition. The other four were fine.

    WinJS.UI.Pages.define("/html/pages/myPage.html", {
            ready: ready,
            updateLayout: updateLayout
        });

    Wednesday, August 01, 2012 4:01 AM