Skip to content

Instantly share code, notes, and snippets.

@chantalgo
Last active December 17, 2015 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chantalgo/5647529 to your computer and use it in GitHub Desktop.
Save chantalgo/5647529 to your computer and use it in GitHub Desktop.
About Navigation in WinJS

Page Navigation

A hyperlink to page2.html

a href="/pages/page2/page2.html"

Direct Hyperlink

Page control Navigation

Page Control

Fortunately, the PageControlNavigator control makes performing this type of navigation fairly easy. The PageControlNavigator code (in your app's navigator.js file) handles the WinJS.Navigation.navigated event for you. When the event occurs, the PageControlNavigator loads the page specified by the event. The WinJS.Navigation.navigated event occurs when you use the WinJS.Navigation.navigate, WinJS.Navigation.back, or WinJS.Navigation.forward functions to navigate. You need to call WinJS.Navigation.navigate yourself rather than using the hyperlink's default behavior. You could replace the link with a button and use the button's click event handler to call WinJS.Navigation.navigate. Or you could change the default behavior of the hyperlink so that when the user clicks on a link, the app uses WinJS.Navigation.navigate to navigate to the link target. To do this, handle the hyperlink's click event and use the event to stop the hyperlink's default navigation behavior, and then call the WinJS.Navigation.navigate function and pass it the link target.

            WinJS.Navigation.navigate("/pages/groupedItems/groupedItems.html");´

You can't change canGoBack, but you can disable the button to hide it and free the history stack.

// disabling and hiding backbutton
document.querySelector(".win-backbutton").disabled = true;
// freeing navigation stack
WinJS.Navigation.history.backStack = [];

READ MORE: http://msdn.microsoft.com/en-us/library/windows/apps/hh452768.aspx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment