2012-01-22 4 views
5

に反映した、私はそうのような& fiter並べ替える必要があり、計算プロパティがあります:私はCollectionViewEmberJSでリストをソートし、そのビュー

のデータソースとしてそのプロパティを使用してい

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(),  

子の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(),  
関連する問題