backbone.js @ でテスト ケースを作成します: http://jsfiddle.net/VWBvs/5/
ルートは次のように定義されます
var AppRouter = Backbone.Router.extend({
routes: {
"/posts/:id" : "getPost",
"/download/*path": "downloadFile",
"*actions" : "defaultRoute"
},
getPost: function(id) {
alert(id);
},
defaultRoute : function(actions){
alert(actions);
},
downloadFile: function( path ){
alert(path); // user/images/hey.gif
},
loadView: function( route, action ){
alert(route + "_" + action); // dashboard_graph
}
});
var app_router = new AppRouter;
Backbone.history.start();
機能を変えると
defaultRoute : function(actions){
alert(actions);
},
に
defaultRoute : function(actions){
var action = actions
},
他のすべてのルートは機能しません。つまり、ダイアログはポップアップしません。
しかし、コードを再変更すると、すべて問題ありません。
それは本当に奇妙で、私を混乱させます。心からSOS……