Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backbone.js and leading hash

Tags:

backbone.js

I have the following problem. Some part of my Backbone application has url like:

site.ru/#profile

When the page is loaded URL changes to:

site.ru/profile

So, the hash was lost. So, I see the problem in navigate function of Backbone:

var routeStripper = /^[#\/]/;
...
var frag = (fragment || '').replace(routeStripper, '');

As I understand this code clean a hash at the begin of URL.

Is it true way to simply delete this line of code to fix the problem? Could you advise me some other ways to fix this.

TIA!

like image 974
Dmitry Belaventsev Avatar asked Apr 14 '12 17:04

Dmitry Belaventsev


1 Answers

Backbone only removes the hash if you enable pushState.

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

http://backbonejs.org/#Router

like image 167
abraham Avatar answered Sep 18 '22 16:09

abraham