var RippleId = Backbone.Model.extend({
initialize: function(toresolve) {
this.url= config.rippleaccount.id.urlModel+toresolve;
this.set('id', toresolve)
}
});
var RippleIds = Backbone.Collection.extend({
model: RippleId,
createIdList: function(toresolves) {
var self = this;
_.each(toresolves, function(toresolve) {
var model = new RippleId(toresolve);
model.fetch({
success: function(model,response) {
self.add(model);
}
});
});
}
});
var toresolvelist = new rippleids();
toresolvelist.createIdList(toresolves);
toresolvelist.toJSON()
doesn't return anything (instead of the collection's objects).
I guess it's a problem of waiting that the collection has been correctly populated but I thought it was ok because I wait for model fetching success before adding it.
When I console.log(toresolvelist)
it shows me that the result is here. But I can't access it through .get
or toJSON
so I guess console.log
is cheating me.
I'm having a hard time identifying what the problem is and I can't solve it.
Thanks a lot in advance!