2011-11-11 9 views
0

私は解決しなければならない状況があります。確かに、人々はここに私が持っているモデルだ...そこのCoffeeScriptでバックボーンを破損するエラーCoffeescriptで生成されたリレーショナルモデル

をバックボーンRelationalを使用している:

class MyCompany.Models.Establishment extends Backbone.RelationalModel 
    defaults: 
    name: null 

class MyCompany.Collections.EstablishmentsCollection extends Backbone.Collection 
    model: MyCompany.Models.Establishment 
    url: '/establishments' 

私もちょうどRelationalModel延長、まだ関係が追加されていません。今、コンソールを介して、私はそれが成功し、サーバー上のモデルを破壊モデルのインスタンスに破棄発行するとき、それは微量で失敗したときに、完全な:それは、バックボーン・リレーショナルのライン235で死んだ

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 

。 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); 
+0

コンソールからモデルを破壊するために使用しているコマンドは何ですか? –

+0

ちょうどmodel.destroy() – Tony

答えて

1

基礎となるBackbone.jsのバージョンを更新する必要があります。理由は次のとおりです。

unregisterを呼び出すと、thisの値が間違っています。 unregisterregisterから結合したイベントに応答して呼び出される:

model.bind('destroy', this.unregister, this); 

3番目の引数がコンテキストを設定すること。しかし、この機能は、changelogが示すように、Backbone 0.5.2として最近追加されました。

+0

この作業。私はただ0.5.3にアップグレードしましたが、それはまだ起こっているようです。私は追跡し、すべてが正しく設定されていることを確認しようとしています。 – Tony

+0

私は、Railsのキャッシュをクリアしてpowを再起動する必要がありました。私はどこかに古いものを提供していました。今働いているようだ。 Trevorのためにそれを追跡してくれてありがとう。 – Tony

関連する問題