0
votes

I have a dynamic-segment route in my app:

this.resource('products', {path: 'products'}, function() {
    this.route('detail', {path: 'detail/:id'})
});

and the models:

App.ProductsRoute= Ember.Route.extend({
    model: function() {
        return this.store.find('product');
    }
});

App.ProductsDetailRoute= Ember.Route.extend({
    model: function(params) {
        return this.store.find('product', params.id);
    }
});

Normally, when I visit the ProductsRoute, that displays a list of products with a {{#each}} loop, the products are ordered by Id;

but if for example I refresh the browser when in route /products/detail/2 and then go to /products, now the first one is the number 2; I guess this is because Ember has already loaded it and does not load again the same record; but is there a possibility of telling Ember to always keep the records ordered?

1

1 Answers

0
votes

Maybe you could try a simple sortBy statement?

App.ProductsRoute= Ember.Route.extend({
    model: function() {
        return this.store.find('product').sortBy('id');
    }
});