mercredi 25 mars 2015

Can't observe computed property

I've got a controller sorting posts first, then there's a filter applied to them. Sadly when I use {{#each post in filteredPosts}} in my template they don't live update.


How can I achieve the sorting on multiple columns (in different directions), then the filtering AND still have new and deleted posts appear in the list live?


import Ember from 'ember';



export default Ember.ArrayController.extend({
sortProperties: ['isPublished:asc', 'createdAt:desc'],
sortedPosts: Ember.computed.sort('model', 'sortProperties'),
filterPost: '',

filteredPosts: function() {
var filterText = this.get('filterPost').toLowerCase()
return this.get('sortedPosts').filter(function(post){
return post.get('title').toLowerCase().indexOf(filterText) > -1
})
}.observes('sortedPosts').property('filterPost'),

});




Aucun commentaire:

Enregistrer un commentaire