I'm trying to update a list of models
from my AppView
linked to my Collection
but I'm not sure how should I do it.
I thought to do it on the render
function, the purpose is to set a specific property I've called treeId
which is 0
by default and I would change it to a different value after the rendering to set a different treeId
html attribute
inside the html template for every model.
render: function() {
console.log("View - App.render");
this.statusOpenedFolder();
var parentTreeId = this.parentTreeId;
_.each(this.collection.toJSON(), function (model, index) {
model.treeId = parentTreeId + index;
console.log("treeId edit " + model.treeId);
});
var assetsChildren = _.template(this.tmplAssetsChildren, {items:this.collection.toJSON()});
this.$currentTarget.find("ul").remove();
this.$currentTarget.append(assetsChildren);
this.delegateEvents();
return;
}
Basically i'll need it to get where is the children of a tree menu.
Obviously the _.each
method don't work because I'm doing it without any reference to the collection, how can I do it?