Question

I have the following routes object:

    routes: {
        "*defaults": "home",
        '#test': 'test'
    }

Here's the url options:

myApp.html // home is called as desired 

myApp.html#test // home is called instead of test

What did I miss?

Was it helpful?

Solution

Per the docs, you don't need the hash mark in the route (that's implied by the Backbone routing convention). Also, the "*defaults" route is going to catch everything, so you should put it last after more specific routes. So, like this:

routes: {
    'test': 'test'
    "*defaults": "home",
}

Should result in myApp.html#test getting routed to test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top