1

I'm new to Ember and recently followed the Ember "getting started" guide to build TodoMVC. Here it is in a jsbin.

Everything works, but now I'm trying to sort the todos by adding sortProperties to the TodosController:

Todos.TodosController = Ember.ArrayController.extend({
    sortProperties: ['title'],
    sortAscending: true,
    ...
});

And in the template, I have this:

{{#each todo in arrangedContent itemController="todo"}}
  ...
{{/each}}

Based on the Ember.SortableMixin documentation, what I'm doing seems to be reasonable but clearly I'm missing something.

Any help would be much appreciated!

PrestaShopDeveloper
  • 3,110
  • 3
  • 21
  • 30
roseweixel
  • 58
  • 1
  • 5

1 Answers1

1

Thanks to stevennunez, I understand what was missing - adding the following code fixed the problem:

Todos.TodosIndexController = Ember.ArrayController.extend({
    sortProperties: ['title'],
    sortAscending: true
});

Without this controller being defined, Ember by default created a "generic" Ember.ArrayController which was being used to render the todos/index template. Thus, the sortProperties placed in the TodosController had no effect.

Community
  • 1
  • 1
roseweixel
  • 58
  • 1
  • 5