I created collection inserting type of JSON TREE.
view.js
views.Livingword = Backbone.View.extend({
render: function(templateName) {
var template = _.template(templateName);
this.$el.html(template({result : this.collection.models}));
_.each(this.collection.models, function(model){
console.log(model.attributes.bathroom);
});
return this;
}
My collections are set they are the picture below.
I want to know how access the model.attributes (that is mean how to access each object?)
I entered console.log
statement that's likeconsole.log(model.attributes.bathroom);
How to access this attribute using underscore.js each
in html??
I really want that its solution.
try this, maybe it is what you want
_.each(this.collection.models, function(model){
console.log(model.attributes.bathroom);
for(var i in model.attributes){
if (model.attributes.hasOwnProperty(i)){
console.log(model.attributes[i]);
}
}
});