Problem with single page navigator pattern. How to unload/stop previous DOM/Javascript execution ? RRS feed

  • Question

  • Hi folks,

    I'm using single page navigation pattern in my app. And so far navigation works fine.. going one page to another page and again coming back to same page and so forth... looks like a browser's back and forward..

    Problem starts here...

    Page 1(P1) fetches data from "n" number of async data sources- a web services. here n is BIG (say 30 xhr). Now, while P1 is busy loading data via ajax requests and meanwhile if someone click on any links from P1 which leads to page 2(P2) and boom.........

    - that code still being executed even i'm in now P2 page... and that javascript code search for DOM elements of P1 which are now no longer exist as navigator has loaded the fragment for P2 page.


    1) how to fix this behavior or is there any way I can tell navigator to "unload the Previous page DOM" when i'm on a specific page ?

    2) What if I remove the single page navigation pattern from my app ? Is there any other way rather than directly using href in anchor <a href="/html/p2.html"> or window.location = p2.html

    3) Is it compulsory to use single page navigator or is it recommended by metro guideline ?

    Here some one has mentioned the same problem of javascript timers using setTimeout() for single page navigation pattern.

    Ref: http://devhammer.net/blog/w8wil-3-timers-using-settimeout-in-a-windows-8-app

    • Edited by Web-Farmer Wednesday, July 11, 2012 1:45 PM
    Wednesday, July 11, 2012 12:23 PM


All replies