backbone icon indicating copy to clipboard operation
backbone copied to clipboard

Backbone.History documentation

Open sharth opened this issue 15 years ago • 6 comments

In short, the documentation for Backbone.History has lots of examples like:

  • Backbone.history.start([options])
  • Backbone.history.start({pushState: true, root: "/public/search/"})

In all of these, Backbone.history.start should be Backbone.History.start.

sharth avatar Nov 09 '11 17:11 sharth

I'm actually not really sure of this bug. I think I'm doing something wrong...

sharth avatar Nov 09 '11 17:11 sharth

Right. Backbone.history is the name of the global instance ... Backbone.History is the name of the History class. The docs are correct. I agree that it's totally confusing.

jashkenas avatar Nov 09 '11 17:11 jashkenas

Its not clear that Backbone.history only becomes available once you instantiate at least one controller

masylum avatar Nov 09 '11 18:11 masylum

It isn't? To quote:

"During page load, after your application has finished creating all of its routers, be sure to call Backbone.history.start(), or Backbone.history.start({pushState: true}) to route the initial URL."

And later...

"When all of your Routers have been created, and all of the routes are set up properly, call Backbone.history.start() to begin monitoring hashchange events, and dispatching routes."

jashkenas avatar Nov 09 '11 18:11 jashkenas

I would say the more key part of the documentation is this:

"History serves as a global router (per frame) to handle hashchange events or pushState, match the appropriate route, and trigger callbacks. You shouldn't ever have to create one of these yourself — you should use the reference to Backbone.history that will be created for you automatically _if you make use of Routers with routes."_

That's the part that I apparently read, but did not remember.

sharth avatar Nov 09 '11 18:11 sharth

IMO I would replace created for instantiated :)

masylum avatar Nov 09 '11 19:11 masylum