我有一個todos列表,我有與他們相關的標籤屬性。在視圖上,我有一個「按標籤排序」按鈕。當我按下該按鈕時,我希望集合按標籤排序。現在什麼都沒有發生。以下是代碼。怎麼了?SproutCore收集排序
In todos.js I have:
Todos.SortingView = SC.TemplateView.extend({
sortBinding: 'Todos.todoListController.sortTodos'
});
and in todoListController, I have:
sortTodos: function() {
Todos.store.find(Todos.Todo).sortProperty('tag');
}
and in the handlebars view I have:
{{#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}}
什麼是您的ListController? – hvgotcodes
Todos.todoListController = SC.ArrayController.create({ //使用一個空數組初始化陣列控制器 內容:[], //功能 sortTodos:函數(){ Todos.store.find(託多斯.Todo).sortProperty( '標籤');} , //功能 }); –