Ember.ArrayProxy更改不会触发把手#each update

ale*_*erg 6 ember.js

我怀疑有一种方法可以更新Ember.Array代理,它将触发ember的通知,但我无法弄清楚如何.

我正在覆盖"content"属性来更新数组.阵列确实更新但视图没有更新.

App.items = Ember.ArrayProxy.create({
    content: [
        Ember.Object.create({ name: 'Me', city: 'new york'}),
        Ember.Object.create({ name: 'You', city: 'boston'})
    ],

    sortByCity: function() { 
        this.set('content', this.get('content').sort(function(a,b) {
            return a.get('city') > b.get('city')
        }));   
    }
});
Run Code Online (Sandbox Code Playgroud)

这是一个演示问题的小提琴http://jsfiddle.net/alexrothenberg/za4Ha/1/

任何帮助表示赞赏.谢谢!

Mik*_*ski 8

修正了它:http://jsfiddle.net/MikeAski/za4Ha/2/(我通过引入一个CollectionView来渲染项目来重构你的代码一点).

您应该使用replaceContent原语来替换ArrayProxy内容并保持绑定绑定...