Possible Duplicate:
Backbone.js - change not triggering while the name change
Backbone - how get this sort out… some part still not clear
in my backbone function, i am keep fetching the data using setTimout
while i fetch the data, i am sending property as {add:true}
so it means, the model which i am getting newly will going to add with existing collection, when the collection get the model added , it should trigger the add
method.
But i am not getting the trigger on the after add process made in my collection. but i am fetching the data in view process, it is not correct.
my collection:
list.collect = Backbone.Collection.extend({
model:list.model,
url : 'data/names.json',
initialize:function(){
this.fetch({success:this.prompter});
this.on("add", this.addOne, this);//it should get triggered while added the model
},
addOne:function(e){
console.log('addone'); // the method not called
}
});
my view :
list.view = Backbone.View.extend({
initialize:function(){
this.collection = new list.collect();
var that = this;
var updateData = function(){
that.collection.fetch({add:true}); // i am passing add:true!
myTimeout = setTimeout(updateData,10000)
}
var myTimeout = setTimeout(updateData,10000)
this.collection.on("reset", this.render, this);
},
render:function(data){
_.each(this.collection.models, function(data){
//console.log(data.get('name'));
})
}
});
any idea about the issue please?