0

successコレクションを取得した後、コールバックを呼び出そうとすると問題が発生します。これがコレクションのコードです。問題は実行中ですexecuteLongPolling

(function() {
window.StatusCollection = Backbone.Collection.extend({
    longPolling : false,
    intervalSeconds : 20,
    model: Status,
    url: function(){
        return this.project.id + 'statuses/';
    },
    initialize : function(){
        _.bindAll(this);
    },
    startLongPolling : function(invervalSeconds){
        this.longPolling = true;
        if( invervalSeconds ){
            this.invervalSeconds = invervalSeconds;
        }
        this.executeLongPolling();
    },
    stopLongPolling : function(){
        this.longPolling = false;
    },
    executeLongPolling : function(){
        var that = this;
        this.fetch({
            success : function(collection, response, options) {
                that.onFetch();
            }
        });
    },
    onFetch : function () {
        if( this.longPolling ){
            setTimeout(this.executeLongPolling, 1000 * this.intervalSeconds);
        }
    }
}); })();

驚いたことに、更新オプションを追加すると機能し、次の行that.onFetch()が呼び出されます。

executeLongPolling : function(){
        var that = this;
        this.fetch({ update: true,
            success : function(collection, response, options) {
                that.onFetch();
            }
        });
    },

backbone-0.9.10 を使用しています。および backbone-relational-0.7.0

何が問題なのですか?ありがとう!

4

1 に答える 1

0

0.9.2 から 0.9.10 にアップグレードした後、コレクションに追加するだけ (私はフェッチを使用しません) が壊れているように見える私の問題の解決策を探しているときに、あなたの問題に遭遇しましたこれらを見てください:

バックボーン投げコレクション[メソッド]関数エラー https://github.com/addyosmani/backbone.paginator/issues/134

または、バックボーンリレーショナルが 0.9.10 でまだ完全に機能していないという事実 https://github.com/PaulUithol/backbone-tastypie/pull/25

于 2013-02-05T16:28:48.177 に答える