0
我試圖摧毀一個模型,我得到「遺漏的類型錯誤:未定義是不是一個函數」當我打電話this.model.destroy({}選項)型號破壞返回undefined不是一個函數
我模式是這樣的:
window.CompanyModel = Backbone.Model.extend({
initialize: function() {
console.log('CompanyModel:initialized');
},
parse: function(response, options) {
return response;
},
});
收藏:
window.CompaniesCollection = Backbone.Collection.extend({
model: window.CompanyModel,
initialize: function() {
console.log('CompaniesCollection:initialized');
},
});
查看:
window.CompaniesView = Backbone.View.extend({
initialize : function() {
console.log('CompaniesView:initialized');
this.companies = new CompaniesCollection();
this.companies.url = function(id) {
return '../src/rest/administration/companies/companies';
};
this.company = new CompanyModel();
},
[...more code...]
confirmDeleteForm : function(event) {
event.preventDefault();
var company_id = $('#company_existing').val();
var self=this;
this.company = this.companies.where({'company_id':company_id});
this.company.destroy({
wait: true,
success: function(model, response) {
console.log('deleted');
$('#deleteModal').modal('hide');
self.cleanForm();
self.getCompanies();
},
error: function(model, response) {
console.log('error');
console.log(model);
console.log(response);
console.log(options);
if (response.status == 500) {
self.showErrorMessage('Se produjo un error en el servidor', 'ERROR');
} else {
self.showErrorMessage(response.responseText, 'ATENCION');
}
}
});
},
任何幫助,將不勝感激。
問候,LN
非常感謝。 – leandronn 2014-11-25 05:02:14