我在尝试在获取集合后调用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。和骨干关系-0.7.0
任何想法有什么不对?谢谢!
答案 0 :(得分:0)
在寻找我的问题的解决方案时遇到了你的问题,只是添加到我的收藏(我不使用fetch)似乎在从0.9.2升级到0.9.10后被打破 Anywho,只是看了你的问题,可能与0.9.10中的fetch更改有关 看看这些:
Backbone throwing collection[method] function error https://github.com/addyosmani/backbone.paginator/issues/134
或许Backbone-relational还没有完全适用于0.9.10这一事实 https://github.com/PaulUithol/backbone-tastypie/pull/25