Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Subroute fails if called before Backbone.history has been started #3

@carpeliam

Description

@carpeliam

I tried initializing a subroute within the initialize of my main router, and this works fine if I start at the root and browse to a route covered by my subroute, but doesn't work if I load a subroute-related path initially. (So, if my subroute covers '#books' and I start at www.books.com and navigate to www.books.com/#books everything is fine; but if I load up www.books.com/#books in my browser, it throws an exception.) The reason for this is that Backbone.history.loadUrl references options.root which won't exist until after Backbone.history.start has been called. And I can't start Backbone.history before I've created my router either. This is with Backbone v0.9.2.

Your initial approach was to create the subroute in a handler of the main router, but I'm getting a stack overflow with that approach in IE (at least IE8, I think IE9 as well). I'll create a separate issue for that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions