我无法弄清楚我做错了什么。我的成功和错误回调不会触发,我从服务器返回JSON响应。任何想法,我在哪里搞砸了?Backbone销毁功能的成功回调不会触发
mysite.city.delete_photo = {
"Model": Backbone.Model.extend({
"id": "deletePhoto",
"initialize": function initialize(id) {
this.url = "/assets/ajax/delete_image.php?img_id=" + id;
}
}),
"View": Backbone.View.extend({
"initialize": function initialize(id) {
_.bindAll(this,
"render",
"success");
this.model = new mysite.city.delete_photo.Model(id);
this.render();
},
"render": function render() {
this.model.destroy({
"cache": false,
"success": this.success,
"error": this.error
});
},
"success": function success(model, data) {
console.log("test");
},
"error": function error() {
message('error', 'This image could not be deleted.');
}
})
};
缩进。绝对缩进。 :) – sje397 2013-03-22 13:34:18
我的编码风格的作品。这不是缩小它的缩进。 – 2013-03-22 13:38:27
我在开玩笑。我对文档的阅读没有提供View类的成功和错误属性。也许你可以在模型中添加'sync'属性,并将错误和成功处理程序作为选项传递给它? – sje397 2013-03-22 13:47:25