Reputation: 44947
I'm looking for a way to clear an ArrayController
, but get an error when sortProperties
:
App.SwatchesController = Ember.ArrayController.extend({
clear: function () {
this.clear(); // Error: Using replace on an arranged ArrayProxy is not allowed.
},
sortProperties: ['occurences']
});
If I remove sortProperties
, it will work just fine. Of course I can clear the controller by doing:
this.set('model', []);
But it would like to stick to clear()
, if possible.
Upvotes: 2
Views: 329
Reputation: 19128
Using just this.clear()
will make the arrangedContent
change, and this isn't allowed. I think it happens because arrangedContent
isn't the source of truth, just the model
property. arrangedContent
is intented to be some reorganized data based on model property, like: filters, orders, sort etc. So you need to always change the source (model
), not the arranged data.
So you need to use this.get('model').clear();
instead of this.clear();
.
Your code updated will be the following:
App.SwatchesController = Ember.ArrayController.extend({
clear: function () {
this.get('model').clear();
},
sortProperties: ['occurences']
});
Upvotes: 2