Take the 2-minute tour ×

I have a backbone js collection with multiple models:

Model 1:
tag: 1
id : 2
name: test

Model 2:
tag: 3
id: 3
name: test3

How do I search the collection for a particular model by tag attribute? Like if I want to find the model with tag=2 ... How do I do that?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Use findWhere:

Returns only the first model in the collection that matches the passed attributes.

collection.findWhere({tag: 2})
share|improve this answer
add comment

Your Answer


