Backbone:Navigate未命中指定的路由

时间:2014-03-05 03:54:07

标签: javascript backbone.js

保存模型后调用导航。

this.model.save({},{
        success: function(model, response, options){
            Backbone.history.navigate('getCampaigns', {tigger: true});
        }
      });

但它永远不会达到指定的路线。
路线等级

var Router = Backbone.Router.extend({
    routes: {
        "":"home",
        "login":"login",
        "getCampaigns":"getCampaigns"
    },
    start: function() {
        Backbone.history.start({pushState:true});
    },
    home: function() {
        var loginView = new LoginView({model: loginModel});
        loginView.render();
        $(".container").append(loginView.el);
    }, 
    login: function(event) {
        event.preventDefault();
    },
    getCampaigns: function() {
        this.dashboardList.fetch();
        $('.container').html(this.dashboardListView.render().el);
    }
});

var app = new Router();
app.start();

1 个答案:

答案 0 :(得分:1)

您的代码中有错误:

Backbone.history.navigate('getCampaigns', {trigger: true}); // not {tigger: true}