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();
            }
        });
    },

我正在使用主干-0.9.10。和骨干关系-0.7.0

有什么想法有什么问题吗?谢谢!

4

1 回答 1

0

在寻找我的问题的解决方案时遇到了您的问题,在从 0.9.2 Anywho 升级到 0.9.10 后似乎只是添加到我的收藏(我不使用 fetch)似乎被破坏了,只要看看你的问题,可能会有一些东西与 0.9.10 中的 fetch 发生变化有关看这些:

骨干投掷集合[方法] 函数错误 https://github.com/addyosmani/backbone.paginator/issues/134

或者也许是 Backbone-relational 在 0.9.10 中还没有完全发挥作用的事实 https://github.com/PaulUithol/backbone-tastypie/pull/25

于 2013-02-05T16:28:48.177 回答