Reputation: 310
I have this JS bin. Does anyone know the reason why, when I modify the user model and click the button to rollback, why the firstName property is being rolled back but not the array custom attribute? Thanks.
http://emberjs.jsbin.com/nunihuco/1/edit?html,js,console,output
Upvotes: 1
Views: 969
Reputation: 47367
Ember Data watches the property itself. The property itself isn't changing, your data inside is. You'd need to change the property for it to be able to rollback
.
this.set('model.listOfStuff', ['hello','world']);
http://emberjs.jsbin.com/nunihuco/2/edit
If you wanted, you could clone and modify. This only works on primitive types though, if you have objects, you'd run into the same thing.
var orig = this.get('listOfStuff'),
newArr = orig.slice();
this.set('listOfStuff', newArr);
newArr[0] = 'asdf';
http://emberjs.jsbin.com/nunihuco/3/edit
Upvotes: 4