2013-11-23 1 views
1

Ember-Model을 사용하기 전에 sortProperties 및 sortAscending을 사용하는 ArrayController를 예상대로 정렬했습니다. 최근에 Ember-Model로 전환했는데 정렬 기능이 더 이상 작동하지 않습니다. 지금까지Ember-Model에서 지원하는 ArrayController를 정렬하는 방법은 무엇입니까?

코드 :

App.Movie = Ember.Model.extend({ 
    rating: Ember.attr(), 
    title: Ember.attr(), 
    watched: Ember.attr(), 
    year: Ember.attr(), 
}); 

App.MoviesIndexController = Ember.ArrayController.extend({ 
    sortProperties: null, 
    sortAscending: null, 

    actions: { 
    sortByAttribute: function (attr) { 
     if (this.get('sortProperties')) { 
     if (this.get('sortProperties')[0] === attr) { 
      this.toggleProperty('sortAscending'); 
     } else { 
      this.set('sortProperties', [attr]); 
     } 
     } else { 
     this.set('sortProperties', [attr]); 
     this.set('sortAscending', true); 
     } 
    } 
    } 
}); 

<table> 
    <thead> 
    <tr> 
     <th {{action "sortByAttribute" "year"}}>Year </th> 
    </tr> 
    </thead> 
    ... 
</table> 

어떤 생각?

들으은

가 나에게 작품처럼 보이는
+0

이 나를 위해 일한입니다 : http://stackoverflow.com/a/16435444/836968 – pkosel

답변

관련 문제