1

From Backbone,

The router helps developer's creation and navigation across views. It is using the href='#page' to trigger general task, but it implies that this will be shown on the browser's navigation bar.

How can I still use Backbones routers functionality without having the navigation bar show that type of detail to the website visitor ?

Thanks.

Mathias-Dev
  • 69
  • 1
  • 7

1 Answers1

0

The fact that the #page hash is displayed in the navigation bar is actually very helpful, because it means that if the user refreshes the page, or bookmarks it for later, the router will be able to load the correct route for you.

If it's just the # sign you don't like, you can use the router's pushState support (docs) to get normal URLs such as domain.com/page instead of domain.com/#page. Just be aware that for older browsers that don't support pushState the # URLs are still used, and you'll need to configure your web server to return the HTML content page for all the sub-page URLs, too.

Unless you have some very pressing need to hide the navigation state, I wouldn't worry about it. Just name your routes in a "user-friendly" way.

jevakallio
  • 35,324
  • 3
  • 105
  • 112
  • clear explanation. I still do not have enough reputation to vote on your answer, yet, I will. Still, from my tests, I regularly come to a situation, where I view a site#page (instantiated by backbone), and upon a refresh, since this page won't exist yet, the user fallback on the home page... Annoying to some of my users. Maybe there is a solution for this. – Mathias-Dev Jan 22 '13 at 18:05
  • @Mathias-Dev, there's a kind of related question open right now, although no great answers yet: http://stackoverflow.com/questions/14460934/backbone-js-routing-for-nested-views. Maybe see if something comes up there, or open another question about that. – jevakallio Jan 22 '13 at 19:39