Reputation: 610
I created this simple JsBin to demonstrate what I'm after.
I have some Fixture data and each item in it has a boolean property called isFavourite. The indexRoute
just displays all the available data along with a second section that displays the items that are favourites. Each item also has a class binding to this isFavourite
property. If it's a favourite, it'll have red text.
There is a second route called dashboard
which only displays a subset of the data from the store. There is also a button to toggle the favourite property. When this is toggled, the change is reflected in the class binding on the index route but the Favourites
section, which is just a repeater still shows the old data.
How do I establish a binding for the repeater so that the items change according to the isFavourite
property?
Upvotes: 0
Views: 903
Reputation:
Try this:
App.IndexController = Ember.Controller.extend({
favourites: function() {
return this.store.filter('documenter', function(x) {
^^^^^^^^^^^^^^^^^
return x.get('isFavourite');
});
}.property('model')
})
The reason this works is that this.store.filter
returns a "live" collection that is updated as things change.
Works for me on your JSBIN.
Upvotes: 1