locked
Problem while navigation

    Question

  • Hi,

    i am building metro style application with javascript, i created three page 

    Home, subhome, Description

    when i am try to navigate....

    Home > Subhome > Description  after it when i am reverse navigate,

    then Home page Directly Assign Description Page, Home page deos not link to subhome

    So what should i do please help me

    Thank You in Advance.

    • Changed type Song Tian Tuesday, December 04, 2012 3:00 PM
    Wednesday, November 28, 2012 7:32 AM

Answers

  • Hi Mehul,

    Just download your code and run it in my test machine. I've debugged in VS 2012 and find that the problem is not caused by navigation, but the script files you've referenced in your application (actually the pages). To clarify this issue, we need to first understand that for Windows Store javascript application, every script file referenced in any page (which will be loaded/navigated through WinJS.Navigation framework) will always be kept in memory (will not be unloaded even if we navigate away from the certain page). So for your project, the data.js file in the "js" folder has defined the "Data" namespace like:

    WinJS.Namespace.define("Data", ....)

    however, in the /pages/Home/subhome/script1.js file, there also exists the same code which defines the "Data" namespace (which overwrite the previous defined one). Since your navigation path path is obtained from "Data.items", this cause the behavior become inconsistent before and after user has navigated to the "subhome" page (which has referenced the script1.js) file.

    Also, I recommend that you always put the folder of each page at the same level (do not nest one page's folder under another). e.g.

    /pages
         /home
         /subhome
         /details
         /about

    this will be more clear to see all the pages exists in your application. here is the msdn reference about the Windows Store javascript app's support on navigation:

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


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Song Tian Tuesday, December 04, 2012 3:01 PM
    Thursday, November 29, 2012 7:23 AM
    Moderator

All replies

  • Hi Mehul_Kanani,

    I think the behavior will depend on how you navigate from one page to another (and reversely). Generally, if you want to use the built-in WinJS navigation framework, then you should make sure all the navigation between different pages are triggered via WinJS.Navigation methods. Other approaches like directly page link via <a href="xxx" /> tag or traditional javascript navigation like window.location.href = .... will break the WinJS navigation.

    If you're following the WinJS.Navigation methods, you can add event handler for the "navigated" event and check the current location and backStack history list (by set breakpoint in VS debugger or print them out) to verify if all the pages you've navigated is pushed into the navigation history stack. e.g.

    WinJS.Navigation.addEventListener("navigated", function (evtInfo) {
     var nav = WinJS.Navigation;
     var currentEntry = nav.history.current;
     var historyStack = nav.history.backStack;
    });


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

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, November 29, 2012 3:32 AM
    Moderator
  • cal you please check my app whats going wrong i send you link there is the navigation problem.

    link:

    http://dl.dropbox.com/u/84839474/app.rar


    Really Thank you So much.

    Thursday, November 29, 2012 6:12 AM
  • Hi Mehul,

    Just download your code and run it in my test machine. I've debugged in VS 2012 and find that the problem is not caused by navigation, but the script files you've referenced in your application (actually the pages). To clarify this issue, we need to first understand that for Windows Store javascript application, every script file referenced in any page (which will be loaded/navigated through WinJS.Navigation framework) will always be kept in memory (will not be unloaded even if we navigate away from the certain page). So for your project, the data.js file in the "js" folder has defined the "Data" namespace like:

    WinJS.Namespace.define("Data", ....)

    however, in the /pages/Home/subhome/script1.js file, there also exists the same code which defines the "Data" namespace (which overwrite the previous defined one). Since your navigation path path is obtained from "Data.items", this cause the behavior become inconsistent before and after user has navigated to the "subhome" page (which has referenced the script1.js) file.

    Also, I recommend that you always put the folder of each page at the same level (do not nest one page's folder under another). e.g.

    /pages
         /home
         /subhome
         /details
         /about

    this will be more clear to see all the pages exists in your application. here is the msdn reference about the Windows Store javascript app's support on navigation:

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


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Song Tian Tuesday, December 04, 2012 3:01 PM
    Thursday, November 29, 2012 7:23 AM
    Moderator
  • its  Awesome, i am thankful  to you as i have being facing this problem since long time.

    thanks and regards,

    Mehul kanani

    Thursday, November 29, 2012 9:15 AM
  • I want another help can you please help me.

    i want slide navigation previous and next to another data item here is the sample image that taken from another app, can you please suggest me how to implement it on my app.

    http://dl.dropbox.com/u/84839474/slide.jpg

    http://dl.dropbox.com/u/84839474/slide2.jpg

    Thanks & Regards

    Mehul Kanani

    Friday, November 30, 2012 4:36 AM
  • Thanks for the reply Mehul.

    Sure. Would you please create a new thread on this new issue?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, November 30, 2012 2:00 PM
    Moderator
  • here is the link of new thread 

    http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/5196fa9a-98a4-450d-ab86-6b04fc2eff4c

    Thanks & Regards

    Mehul Kanani

    Saturday, December 01, 2012 3:54 AM