Answered by:
Change in the navigator.js functionality in 8.1 - use 8.0 navigator.js if you run into this issue

Question
-
Hi,
Scenario is pageA navigating to pageA
In 8.0, unload() would be called first, then ready(). This is good.
In 8.1 ready() is being called first, then unload(). This leave the page in bad state, since ready() should be called after unload().
Is there a corrected navigator.js for 8.1 ?
Thanks
PS In case you're wondering why pageA->pageA, because the passed in options, the 2nd arg can be different:
WinJS.Navigation.navigate(Application.navigator.home, { state: state1 });
WinJS.Navigation.navigate(Application.navigator.home, { state: state2 });
http://endorsay.com
- Moved by Ryan BolzMicrosoft employee Thursday, October 17, 2013 7:05 PM support request per 8.1 launch
- Edited by Endorsay Thursday, October 24, 2013 6:41 AM add "so ignore 8.1?"
- Edited by Prashant H PhadkeMicrosoft employee, Moderator Thursday, November 7, 2013 4:36 PM this is a change in functionality not a regression
Wednesday, October 16, 2013 9:54 AM
Answers
-
Thanks Prashant. Ignoring the 8.1 navigator.js works.
http://endorsay.com
- Marked as answer by Endorsay Saturday, October 26, 2013 4:09 AM
Saturday, October 26, 2013 4:09 AM
All replies
-
Hello,
I have been able to reproduce the issue you have mentioned. It sounds like a bug, but I will check and get back to you!
Regards,
Prashant.
Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz
Thursday, October 17, 2013 1:10 AMModerator -
Thank you Prashant :)
http://endorsay.com
- Edited by Endorsay Thursday, October 17, 2013 9:23 AM
Thursday, October 17, 2013 9:22 AM -
Hello,
It seems like the change in order is actually by design on 8.1 and was intentional. Since it breaks your current logic where you are trying to reload your page with a different state, you can probably have a routine inside the page that changes the state directly without navigating.
If you are creating a generic page for different views which end up in the navigation stack, then you can make a function in the page do whatever you want to do for unloading first, and then do the navigation to the new state. This will make sure that you have control over the order rather than relying on the order of method calls.
Thanks,
Prashant.
Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz
- Marked as answer by Jamles HezModerator Wednesday, October 23, 2013 9:10 AM
- Unmarked as answer by Endorsay Thursday, October 24, 2013 6:40 AM
Thursday, October 17, 2013 9:51 PMModerator -
Thanks Prashant. Code can be written to do virtually anything and that is not the point.
The original question was: is there a corrected navigator.js for 8.1, so your last response needs clarification.
What is the recommended thing to do with navigator.js when migrating from 8.0 to 8.1 ?
Is it:
A) keep using 8.0 navigator.js and ignore 8.1 ?
B) replace with backwards-compatible 8.1 navigator.js ?
I am not saying that 8.1 navigator.js needs to be changed, but if the answer is B), it would help if a backwards-compatible version of navigator.js was provided.
Thanks.
http://endorsay.com
Thursday, October 24, 2013 6:40 AM -
There is no corrected version of 8.1 navigator.js. The behavior that you are seeing is due to the changed behavior in the navigator.js functionality of Windows 8.1.
If you are targeting your apps for Windows 8.1, you will need to use the latest version of the navigator.js - which means you will need to change and adjust your code accordingly due to the changed behavior.
Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog
Saturday, October 26, 2013 1:19 AMModerator -
Thanks Prashant. Ignoring the 8.1 navigator.js works.
http://endorsay.com
- Marked as answer by Endorsay Saturday, October 26, 2013 4:09 AM
Saturday, October 26, 2013 4:09 AM -
Hi,
I'm having the same issue so i reverted to the 8.0 navigator.js. Navigation goes well but the "back" functionality is broken on some pages. It just crashes the app and it gets into the "terminateAppHandler" function in base.js (the "debugger;" catch-all instuction) with no stack trace and no exception.
It feels like a global Windows issue, some background stuff maybe. Do the "back" function work for you with the old navigator.js?
Thanks,
Fabien
Sunday, October 27, 2013 6:16 PM -
Just found an answer to my own issue and i believe you should look at it too. If you are using the 8.0 navigator.js, there will be duplicated code handling the back key pressed (like the one on your mouse if you have one). Basically, in ui.js, you have:
function backButtonGlobalMSPointerUpHandler(event) {
// Responds to clicks to enable navigation using 'back' mouse buttons.
if (event.button === MOUSE_BACK_BUTTON) {
nav.back();
}
}and in navigator.js 8.0, you have a listener as well so both call nav.back() and it makes the app crash.
Quick fix is to comment this line in navigator.js 8.0:
document.body.onmspointerup = this._mspointerupHandler.bind(this);
Sunday, October 27, 2013 8:33 PM -
Thanks for the tip. I haven't tried it but I also remember removing some thing about the back behavior.
I was hoping Microsoft would provide a fix, instead of each of us commenting/modifying different bits.
http://endorsay.com
Monday, October 28, 2013 3:44 AM -
True, and this one was very hard to debug as it just reaches the catch-all breakpoint with no information whatsoever. The fact that the navigator is not bundled with WinJS is a little strange anyway but it saved me (us) here.
The new navigator.js behaviour is really weird, i don't know why unload is called after, maybe for transitions of something. It also broke all my code because i was selecting DOM element on document and in the "ready" function, there was 2 elements with the same class, the one from the previous page and the new one. Trick is to use the page parent element (passed as an argument to the ready function) to select DOM nodes, so that you are sure you are targeting the new page.
Fabien
Monday, October 28, 2013 8:20 AM -
I am having the same issue. I used navigator.js as in 8.0 and commented out onmousepointerup line as suggested over here. Everything works fine now, but whenever I run my project it gives warning:
"The method Windows.UI.ViewManagement.ApplicationView.get_value has been deprecated...."
HOw to fix it?
sonal
Wednesday, November 6, 2013 12:23 AM -
You have to remove references to it in the file. Such as:
this._lastViewstate = appView.value;
Basically, the ApplicationView manipulation that was done in navigator.js from Windows 8.0 is now useless and should be removed.
- Proposed as answer by SonalMac Friday, November 8, 2013 7:56 AM
Wednesday, November 6, 2013 12:34 AM