Skip to content

Ignore hash-part in loadUrl when hashChange = false #2765

Closed
@nikcorg

Description

@nikcorg

I'm working on an app where we rely solely on pushState. For browsers who don't support it, we simply fall back to regular page loads.

Why I opened an issue, is really because the way Backbone handles routes declared in the Router.routes hash. As it is now, Backbone will intelligently treat hash URLs equivalent to non-hash URLs, even when pushState is true. On Backbone.history.start() a possible hash containing URL is replaced with a non-hash version. All well and good.

But the default behaviour of loadUrl is to treat the URL as a complete unit, which becomes a problem if you also want to support URLs with hashes in them. In this case a route will not match, unless you declared it as a RegExp in Router.initialize.

To tackle this, I currently override the default loadUrl with a version that strips the hash before calling the original loadUrl.

Personally, I would be interested in seeing either a new configuration setting that would enabled this behaviour in Backbone core, or finding a combination of current configuration that would have this behaviour.

I would definitely be interested in contributing a PR for this, should this be deemed a worthy idea. Otherwise, I suppose I'll just keep monkey patching...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions