Changes to Ember.ArrayProxy do not start steering wheels #each update

I suspect there is a way to update the Ember.Array proxy that will trigger ember notifications, but I cannot figure out how to do this.

I am overwriting the content property to update the array. The array updates, but no.

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') })); } }); 

Here's a script demonstrating the problem http://jsfiddle.net/alexrothenberg/za4Ha/1/

Any help is appreciated. Thanks!

+6
source share
1 answer

Fixed: http://jsfiddle.net/MikeAski/za4Ha/2/ (I revised your code a bit by introducing CollectionView to display the elements).

You must use the replaceContent primitive to replace the contents of ArrayProxy and bind the bindings ...

+8
source

Source: https://habr.com/ru/post/912597/


All Articles