Reputation: 6895
I have a Backbone Router:
class X.Routers.Main extends Backbone.Router
routes:
'/': 'home'
'pageb': 'actionb'
'pagec': 'actionc'
Pages B and C work, but navigating to http://domain.ext/ results in a page reload instead of triggering the right route.
How can I prevent this?
Upvotes: 11
Views: 3069
Reputation: 94
So my routes configuration would be like:
routes = {
'': 'home',
'pageb(/)': 'actionB', // so /pageb or /pageb/ will call the same function
'pagec(/)': 'actionC', // so /pagec or /pagec/ will call the same function
'*action': 'defaultAction' // you can use it to render 404, or call home function
}
Hope this help
Upvotes: 4
Reputation: 22728
You can either set "*path": "home"
as your last route which will make it a default route or set ""
(instead of "/"
)as your first route (which means root directory)
Upvotes: 17