バックボーンルータのドキュメントに記載されているルート方法を試しましたが、ルータの「ルート」オブジェクトを調べると、追加されたルートが表示されません。
ルータのルートオブジェクトは、拡張機能に渡したハッシュだけです。
実際のルートがBackbone.historyオブジェクトに追加されます。
したがって、Router.route()関数を使用すると、ルータのルートハッシュは変更されませんが、実際にルートがBackbone.historyに追加され、期待どおりに動作します。
Workspace = Backbone.Router.extend({
routes: {
"help": "help", // #help
"search/:query": "search", // #search/kiwis
"search/:query/p:page": "search" // #search/kiwis/p7
},
help: function() {
console.log("help");
},
search: function(query, page) {
console.log("search",query,page);
},
new: function() {
console.log("new");
}
});
Main = Backbone.View.extend({
tagName: 'div',
initialize: function() {
app.route('new','new');
},
render: function() {
return this;
}
});
app = new Workspace();
Backbone.history.start();
main = new Main();
app.navigate('new',{trigger:true}); //=> "new"
ライブの例で:http://jsfiddle.net/edwardmsmith/XsDQu/4/