2012-01-22 1 views
5

뷰에 반영 갖는EmberJS의 목록을 정렬하고 내가 & fiter과 같이 분류한다 계산 된 특성이

sortedFilteredChildren: function() { 
     console.log("sortedFilteredChildren()"); 
     var filtered = this.get("children").filterProperty("archived",false); 
     var sorted = filtered.slice().sort(function(a,b){ 
      return a.get("order") - b.get("order"); 
     }); 
     return sorted; 
}.property("@each.order","@each.parent_id","EpicApp.filterOptions.viewArchived").cacheable(),  

내가 CollectionView

의 데이터 소스로 해당 속성을 사용하고 있습니다를

자식 중 하나의 order 속성을 변경하면이 속성은 다시 평가되지 않습니다. 즉, console.log 행이 다음을 수행 한 후에 표시되는 것을 볼 수 없습니다.

child.set("order",10); 

내가 뭘 잘못하고 있는지 알 수 있습니까?

답변

4

마지막으로 알아 냈습니다 ...

반환 값에 @each를 적용 할 것을 생각했습니다. 즉, 반환 값에있는 객체의 주문 속성 중 하나가 변경된 경우 다시 평가됩니다.

하지만 은 정확하지 않습니다.입니다. @each는 계산 된 속성이있는 객체에 적용됩니다. 그래서

이 내가해야 할 일을했을, 내가 필요한 일을 할 수있는 "아이가. @ each.order"

sortedFilteredChildren: function() { 
    console.log("sortedFilteredChildren()"); 
    var filtered = this.get("children").filterProperty("archived",false); 
    var sorted = filtered.slice().sort(function(a,b){ 
     return a.get("order") - b.get("order"); 
    }); 
    return sorted; 
}.property("[email protected]","[email protected]_id","EpicApp.filterOptions.viewArchived").cacheable(),  
관련 문제