I have a model like this
var myModel = Backbone.Model.extend({
defaults: {
a: '',
b: '',
c: ''
}
});
My collection myCollection gets populated with the data and the c value is a list of objects.
I am trying to figure out how I can lookup a value within myCollection such that it matches the items within my models c and returns that model if a match is found ?
The values in c are objects like
"c": {"1": {}, "2": {}, "3": {}}
Use the
find()function, which iterates over the collection and returns the first model that matches your conditions. Something like this:Or use
filter()instead offind(), to get all of the models that pass the condition.