Is it possible to have optional parameters in a Backbone.js route?
e.g this:
routes:
\"search/[:query]\": \"searchIndex\"
instead of:
As of Backbone 0.9.9, you can add optional paramaters with parentheses.
For example in your routes object you can define an optional route part like this:
routes: {
"organize(/:action)": "displayOrganize"
}
Now the url path will match /#organize
and routes like /#organize/create
.
Keep in mind that if you need routes like /#organize/
(with a trailing slash) to be recognized, you can do:
routes: {
"organize(/)(:action)": "displayOrganize"
}