locked
WinJS Navigation + Multitouch Events

    Question

  • Hi, I am using WinJS.Navigation.navigate method to navigate between pages. It is working correctly. On the other hand I have two HTML elements (<div>) which are attached to "click" event. Its handlers are intentionally triggering WinJS.Navigation.navigate, the problem arise due that I am using a multitouch device and when I simultaneously touch this elements the application crash because is trying to navigate to both pages at the same time.


    Is there any workaround to solve this behavior?


    Wednesday, August 08, 2012 12:03 AM

Answers

  • The javascript is not multi-threaded so you can block all navigation in your code with a simple Boolean test.  Something like this.

    // make this a global var in your anonymous function...

    var canNavigate = true; //set this in the construction of the page like in ready:

    function clickLink1(event){

    if (canNavigate){

    canNavigate = false;

    // do the navigation

    }

    }

    function clickLink2(event){

    if (canNavigate){

    canNavigate = false;

    // do the navigation

    }

    }

     

    -Jeff


    Jeff Sanders (MSFT)

    • Marked as answer by Dino He Monday, September 24, 2012 3:23 AM
    Wednesday, August 08, 2012 1:08 PM
    Moderator