warum route von backbone muss die default-route

Erstelle ich einen test-case mit backbone.js @:
http://jsfiddle.net/VWBvs/5/

Route ist definiert als

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();​

Wenn ich die Funktion

  defaultRoute : function(actions){
            alert(actions);
        },

zu

defaultRoute : function(actions){
            var action = actions
        },

alle anderen Routen wird nicht funktionieren, was bedeutet, dass kein Dialogfeld erscheint.

Aber wenn rechange code ,ist alles ok.

Es ist wirklich komisch und macht mich verwirrt.
SOS-mit freundlichen GRÜßEN ......

InformationsquelleAutor Dennis | 2012-04-17
Schreibe einen Kommentar