locked
Anyone seen issues when clicking the win-backbutton and the current page refreshes?

    Question

  • Right now when you click an item in our code you navigate to an overview.html. The win-backbutton needs to be clicked twice to go back to the previous page, as the first click simply refreshes the current page.

    Any ideas on where to take a peek?

    p.s. No I can't share source code :)

    Monday, March 05, 2012 10:26 PM

Answers

  • Found the issue, we were attaching a click event twice to an item to navigate it. So I guess it was navigating to the overview page, then navigating instantly and unnoticably to the overview page again.

    Kind of seems like a bug with attaching click events, no? I'd figure if you add the same event the first one would be destroyed and the new one would be attached.

    Monday, March 05, 2012 10:42 PM

All replies

  • Found the issue, we were attaching a click event twice to an item to navigate it. So I guess it was navigating to the overview page, then navigating instantly and unnoticably to the overview page again.

    Kind of seems like a bug with attaching click events, no? I'd figure if you add the same event the first one would be destroyed and the new one would be attached.

    Monday, March 05, 2012 10:42 PM
  • Please share the whole source code and all your secret documents! Just kidding. ;)

    So the thing about the back button is that each app can implement it their own way (and thus there's no generic fix for your problem). My advice would be to set a watch on WinJS.Navigation and set breakpoints onFragmentLoad and anywhere that class is called.

    When you navigate to overview.html inspect the WinJS.Navigation.history array and see what's there. Maybe you have a bug where you end up navigating the page twice in quick succession. Or maybe there's a bug with the handler on the back button.

    Another thing: in the Customer Preview you can create a new "Grid" WinJS application and then take a look at the navigator.js file in that project. This new navigation implementation is cleaner and more self-contained than the one that was in the Developer Preview.


    Senior Dev for Windows Phone Services

    Monday, March 05, 2012 10:50 PM
  • Kind of seems like a bug with attaching click events, no? I'd figure if you add the same event the first one would be destroyed and the new one would be attached.

    Not really, sometimes you want multiple handlers for a single event. Alternatively you can set element.onclick = myFunction. This should replace the previously set handler.

    Senior Dev for Windows Phone Services

    Monday, March 05, 2012 11:21 PM