Erik
Erik

Reputation: 14750

backbone.js. Hide routing urls (in browser's url bar)?

I'm studying in backbone.js and I like the routing system. But all users of my site can see there requests, like: http://example.com/#/projects and so on.

How can I hide the routing from a browser's url bar but use that cool backbone feature?

Upvotes: 1

Views: 1051

Answers (2)

Tom Tu
Tom Tu

Reputation: 9593

You can put your whole website in an iframe 100% width/height of the page and have your address bar always show root URL...

It will work though it will kill the whole idea behind routes which are supposed to give users fast access to all the states of the app directly with the URL and make any route in your app be bookmarkable and shareable.

Though in the end it's your call :) if you think it's the bet for your app - you know best!

Upvotes: 0

Sander
Sander

Reputation: 13431

I'm not 100% sure what you want, but if you are asking to remove everything after your domain and keep http://mysite.com in the address bar, without the hashes (#projects/10) i think you will be dissapointed.

as far as i know, you cannot remove that, since the history and the routing depend on those hashes, thanks to that part of the url, it knows which route you are trying to fetch.

however, it is possible to remove the /#/ part... and make it http://mysite.com/projects

for that you need to use pushstate in the router like this:

Backbone.history.start({pushState: true});

Upvotes: 2

Related Questions