我無法弄清楚我做錯了什麼。我的成功和錯誤回調不會觸發,我從服務器返回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