Reputation: 16768
I'm retrieving posts using findAll
(because it auto-updates when new posts are pushed to the store).
Therefore I'm doing the sorting in the controller using the SortableMixin
.
You can specify multiple sort-properties but the sort-direction for both properties are different.
It would isPublished -> Ascending, createdAt -> Descending (Show drafts first, then the rest starting with the latest).
sortProperties: ['isPublished','createdAt'],
sortAscending: false
How can I make this work without sacrificing the auto-updating template?
Upvotes: 1
Views: 72
Reputation: 37379
According to this article, you can do something like:
items: [ /* blah blah */ ],
sortProperties: ['isPublished:asc', 'createdAt:desc'],
sortedItems: Ember.computed.sort('items', 'sortProperties')
Personally I always just write a custom sortFunction
when using the SortableMixin
, but this looks like a nifty shortcut.
Upvotes: 1