Transition to object other than firstObject


#1

From within one route I can easily transition to another route using get('firstObject') as explained in the documentation.

However, I would also like to do the transition based on the following:

  • topmost object after controller has sorted the content
  • a given object with a given attribute, e.g. method.find({name: 'Inbox'})

Not so sure that the afterModel is the best hook to use for this.

Here’s how I do it now:

App.FoldersIndexRoute = Ember.Route.extend({
    afterModel: function() {
        var firstObject = this.modelFor('folders').get('firstObject');
        if (firstObject) {
            this.transitionTo('folder', firstObject);
        } else {
            this.transitionTo('folders');
        }
    }
});