I have two objects as follows:
AC.Category = DS.Model.extend({
name: DS.attr('string'),
order: DS.attr('number'),
subcats: DS.hasMany('AC.SubCategory')
});
AC.SubCategory = DS.Model.extend({
name: DS.attr('string'),
order: DS.attr('number'),
category: DS.belongsTo('AC.Category')
});
I'm trying to output all the categories in order (by their 'order' properties) via my IndexRoute. So the code looks something like this:
AC.IndexRoute = Ember.Route.extend({
model: function() {
return AC.Category.find();
}
});
AC.IndexController = Ember.ArrayController.extend({
sortProperties: ['order'],
sortAscending: true
});
This sorts the top-level categories fine, but I can't figure out how to submit the sub-categories so I can output those in order.
How would I go about doing this in Ember, or should I just do it server-side and pass the data through the API already sorted?