I am struggling with sorting a list of todos based on their associated tag property. I have added a "Sort By Tag" button in the view, but when clicked, nothing happens and the collection remains unsorted. Can you please help me identify what is wrong with the code below?
This is my code snippet from todos.js:
Todos.SortingView = SC.TemplateView.extend({
sortBinding: 'Todos.todoListController.sortTodos'
});
Here is the sortTodos function defined in todoListController:
sortTodos: function() {
Todos.store.find(Todos.Todo).sortProperty('tag');
}
And this is how I implemented it in the Handlebars view:
{{#view Todos.SortingView id="stats"}}
{{#view SC.Button classBinding="isActive" target="Todos.todoListController" action="sortTodos"}}
Sort By Tag
{{/view}}
{{/view}}
{{#collection SC.TemplateCollectionView contentBinding="Todos.todoListController" itemClassBinding="content.isDone"}}
{{view Todos.MarkDoneView}} - Tag - {{content.tag}}
{{/collection}}