Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember Data models not becoming dirty when relationships are modified

I've got a model in my Ember application that has a hasMany relationship:

App.Book = DS.Model.extend({
  tags: DS.hasMany('tag')
});

The problem is that when adding/removing a tag to/from a book, the book model itself does not become "dirty". For example:

book = this.store.find('book', 123);
book.get('tags.length')
==> 0
tag = this.store.find('tag', 456);
book.get('tags').pushObject(tag);
book.get('tags.length')
==> 1
book.get('isDirty') // should be true, but is false
==> false

It seems to me that book instance should now be dirty since one of its relationships was changed. What am I doing wrong?

like image 227
NudeCanalTroll Avatar asked Oct 21 '13 20:10

NudeCanalTroll


1 Answers

Temporary solution is to manually call record.send('becomeDirty') after modifying the record's relationships.

like image 117
NudeCanalTroll Avatar answered Oct 22 '22 04:10

NudeCanalTroll