Because it's possible to use multiple Routers
at once (although it's not generally recommended, as we'll discuss later in the chapter), Backbone has a separate global object known as Backbone.history
that handles history management. It is important to understand, however, that this object doesn't actually replace your browser's history; instead, it simply helps to manage what gets added to the history and when.
When you load a page that uses a Backbone Router
, you need to invoke the start
method of this history object in order to tell Backbone to begin routing. This start
method also lets you tell Backbone which routing technology you need to employ. If you want Backbone to rely on hash-based routing, you can simply call the this
method without any arguments:
Backbone.history.start();
If instead you wish to use pushState-based routing, you need to provide one extra argument to indicate it:
Backbone.history.start({pushState: true});
3.22.61.187