我正在使用Backbone和bootbox。 这是我的视图内的代码:
confirm : function(result) {
if (result === true) {
var that = this;
this.model.set({completed: '1'}); // Exception here
this.model.save(
null, {
success: function (model, response) {
Backbone.history.navigate("index", true);
},
error: function(model, response) {
that.model.set({completed: '0'});
var responseObj = $.parseJSON(response.responseText);
bootbox.alert(responseObj.message);
}
});
}
},
completeProcess : function(event) {
event.preventDefault();
this.model.set({completed: '1'});
bootbox.confirm("Confirm?", this.confirm );
}
我遇到了这个错误:
有没有一种方法可以从视图中传递引用?Uncaught TypeError: Cannot call method 'set' of undefined
_.bind
相对于标准的Function.prototype.bind
有什么优势?向后兼容性吗?我没有看到其他内容。 - Justin Morganbind
可用,underscore 将使用它。 - Jack