Reputation: 4969
How do I find the relevant model where its name equals something? I've tried: this.get('content').findProperty('name', name)
, but it doesn't appear to work. I suppose it'd work if my enumerable wasn't stuffed full of models...
Upvotes: 2
Views: 1705
Reputation: 16153
Use findProperty
/ find
on your Ember.ArrayController
instance, see http://jsfiddle.net/pangratz666/kPmHr/:
App.peopleController = Ember.ArrayController.create({
content: [
App.Person.create({ name: 'Adam' }),
App.Person.create({ name: 'John' }),
App.Person.create({ name: 'Adam' })
],
findByName: function(name) {
var found = this.findProperty('name', name);
console.log('found model %@'.fmt(found));
}
});
App.peopleController.findByName('Adam');
Upvotes: 2