Reputation: 331
The model automatically updates if I use:
ST.FiltersSymbolsRoute = Ember.Route.extend({
model: function() {
return this.store.find('filter');
}
});
But when I introduce a query, the model does not automatically update:
ST.FiltersSymbolsRoute = Ember.Route.extend({
model: function() {
return this.store.find('filter', {isSymbol: true});
}
});
Here's the fiddle: http://jsbin.com/yeyiroyo/1/2
To replicate the bug, click Symbols, click "+", type something, and hit enter You'll notice that nothing happens, but if you click Users, then Symbols again -- you'll notice that the model has updated. How can we make it update immediately?
I think what I need to do is have a hook that refreshes the model here:
filter.save().then(function(){
//reload the model
});
Upvotes: 2
Views: 358
Reputation: 4381
The query is going to return a record array not a individual record.
model: function() {
return this.store.find('filter', {isSymbol: true}).then(
function(results) {
return results.get('firstObject')
}
);
}
If you want to return the record array and have it populate automatically then do:
model: function() {
return this.store.filter('filter', {isSymbol: true}, function(record) {
return record.get('isSymbol') === true;
});
}
Here is a good write up.
http://emberjs.com/guides/models/frequently-asked-questions/
Upvotes: 1