Nav.js is a wrapper around History.js that is included when a VS11 SPA project is created.
We create a NavHistory object as follows:
var nav = new NavHistory({
params: { view: 'View1' },
onNavigate: function (navEntry) {
alert("Display" + navEntry.params.view);
}
}
});
nav.initialize({ linkToUrl: true });//Nothing works if set to false
Next we handle a menu click event, which causes the view to change - hence we want to add that to the browser back button history. We do that by calling nav.navigate:
Hi, Christoff, I believe this is because of the line:
params: { view: 'View1' },
which is being initialised with the default view. This triggers a callback on the onNavigate immediately. I can't tell you exactly because we wrote some wrapper code around this, and now it's difficult to tell what the original was up to. Noel
Member
2 Points
17 Posts
Nav.js onNavigate being called twice
Apr 22, 2012 03:41 PM|Noel Abrahams|LINK
Hi,
Nav.js is a wrapper around History.js that is included when a VS11 SPA project is created.
We create a NavHistory object as follows:
Next we handle a menu click event, which causes the view to change - hence we want to add that to the browser back button history. We do that by calling nav.navigate:
The problem: After the initial page re-load, when the menu item is clicked, we get one alert of "Menu clicked", but 2 alerts of "Display View2".
Can someone please advise on a solution?
Thanks!
None
0 Points
1 Post
Re: Nav.js onNavigate being called twice
Jan 11, 2013 05:22 AM|christoffleroux|LINK
Hi Noel, did you manage to solve the problem. I'm having the same issue here.
Regards
Christoff
Member
2 Points
17 Posts
Re: Nav.js onNavigate being called twice
Jan 15, 2013 07:42 AM|Noel Abrahams|LINK
Hi, Christoff, I believe this is because of the line:
which is being initialised with the default view. This triggers a callback on the onNavigate immediately. I can't tell you exactly because we wrote some wrapper code around this, and now it's difficult to tell what the original was up to. Noel