I am having an issue trying to get called a success
callback after fetching a collection. Here is the code from the collection, the problem is excuting 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);
}
}
}); })();
Surprisingly, when I add the update option it works and the line that.onFetch()
is called:
executeLongPolling : function(){
var that = this;
this.fetch({ update: true,
success : function(collection, response, options) {
that.onFetch();
}
});
},
I am using backbone-0.9.10. and backbone-relational-0.7.0
Any ideas what's wrong? Thanks!