Closed matthewdordal closed 9 years ago
A quick glance looks like the _dirtyAttributes
get modified when the computed property is set. Pushing an object to an array does not actually replace the array, so your not calling set on the computed property.
So we probably need to add an arrayObserver to Array
values. In order to set the dirtyAttributes when the array is modified.
A work around for now would be to replace the array on the model.
var keywords = this.get('model.keywords');
keywords.pushObject(keyword);
this.set('model.keywords', keywords.slice(0));
This has some performance concerns for large data sets, but it might be an acceptable workaround until this can be fixed.
Thanks, @raytiley. This was driving @matthewdordal and I nutty yesterday.
@ryanricard If you want dirty checking of arrays, they have to be modeled as hasMany
relationships.
For reference, this is a duplicate of #259
When defining an Array attribute type, exactly like the documentation states, the
isDirty
flag on the model is not being set to true when objects are pushed (e.g.this.get('model.keywords').pushObject(keyword)
).This is the implementation in question:
I debugged ember-model a bit and found
Ember.attr
use ofEmber.computed
is not recalculating for changes to properties of type Array. https://github.com/ebryn/ember-model/blob/master/packages/ember-model/lib/attr.js#L55Is there a better practice for persisting a model property array of primitive values?