I've got an array of pages that I'm sorting by title like so:
PagesController = Ember.ArrayController.extend
sortProperties: ['title']
I'm also trying to redirect to the first item in the array when the user hits the pages.index
route.
PagesIndexRoute = Ember.Route.extend
redirect: (model) ->
page = model.get 'firstObject'
@transitionTo 'page', page if page?
Problem is, the firstObject
is not the first item in the sorted array, so the user is plopped in somewhere in the middle of the list. In the template, I can loop through the arrangedContent
property in order to get the sorted array. However, in the route, I have no access to that property or the sorted array.
How can I redirect to the first object in the array, after the array has been sorted alphabetically?
Aucun commentaire:
Enregistrer un commentaire