Quantcast
Channel: Adam Zwakk » Tutorials
Viewing all articles
Browse latest Browse all 10

Snippet: Group By with Collections in BackboneJS

0
0

Here’s a way to group your collection data via exact attribute values using BackboneJS and UnderscoreJS.

this.categories = _.groupBy(this.collection.models, function(row) {
	return row.attributes.{attribute you want to group by};
});

this.categories should be a new object with your data grouped by the attribute you selected.

The tricky part was returning back the attributes of each model by going row.attributes.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images