我有一種情況必須簡單解決,我猜想。當然人正在使用骨幹關係與CoffeeScript的有...錯誤破壞用Coffeescript生成的骨幹關係模型
這裏有一個模式,我有:
class MyCompany.Models.Establishment extends Backbone.RelationalModel
defaults:
name: null
class MyCompany.Collections.EstablishmentsCollection extends Backbone.Collection
model: MyCompany.Models.Establishment
url: '/establishments'
我還沒有添加任何關係呢,只是延長RelationalModel。現在,通過控制檯時,我發出了一個摧毀它成功地破壞了服務器模型上的模型的實例,但完全失敗時與跟蹤:
Uncaught TypeError: Object #<Establishment> has no method 'getCollection'
_.extend.unregister
Backbone.Events.trigger
Backbone.RelationalModel.Backbone.Model.extend.trigger
_.extend.destroy.options.success
jQuery.extend._Deferred.deferred.resolveWith
done
jQuery.ajaxTransport.send.callback
它死在骨幹關係的235線。 js 0.4.0,因爲「this」是我想的模型,而不是它應該是的,模型沒有「getCollection」方法。
任何想法我做錯了,或者我應該報告錯誤?作爲參考,這裏的Javascript咖啡生成:
(function() {
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor;
child.__super__ = parent.prototype;
return child;
};
MyCompany.Models.Establishment = (function() {
__extends(Establishment, Backbone.RelationalModel);
function Establishment() {
Establishment.__super__.constructor.apply(this, arguments);
}
Establishment.prototype.defaults = {
name: null
};
return Establishment;
})();
MyCompany.Collections.EstablishmentsCollection = (function() {
__extends(EstablishmentsCollection, Backbone.Collection);
function EstablishmentsCollection() {
EstablishmentsCollection.__super__.constructor.apply(this, arguments);
}
EstablishmentsCollection.prototype.model = MyCompany.Models.Establishment;
EstablishmentsCollection.prototype.url = '/establishments';
return EstablishmentsCollection;
})();
}).call(this);
您使用什麼命令從控制檯銷燬模型? –
just model.destroy() – Tony