Default Routes in a Backbone.js controller?

Try adding this additional route as the last route in your controller:

'*path':  'defaultRoute'

and then handle it like this:

defaultRoute: function(path) {
    this.showListView();
}

This assumes the list route is your preferred default. This should work since Backbone.js will match the routes in order, but will always match the ‘splat’ route.

Leave a Comment