Ember Model.isDirty - or not
Ember Model.isDirty - or not
In Ember, if you have models like this:
var Tag = DS.Model.extend({
name: DS.attr('string'),
person: DS.belongsTo('person')
});
var Person = DS.Model.extend({
name: DS.attr('string'),
tags: DS.hasMany('tag')
});
Then did something like this:
var tag1 = this.store.find('tag', 1);
tag1.get('isDirty'); //returns false
tag1.get('name'); //return null
tag1.set('name', 'foo');
tag1.get('isDirty'); //returns true
That would be the obvious outcome, right?
However, if you do this:
var tag1 = this.store.find('tag', 1);
var thatGuy = this.store.find('person', 1);
tag1.get('isDirty'); //returns false
tag.get('person'); //returns null
tag1.set('person', thatGuy); //set person on tag
tag1.get('isDirty'); //returns false
Because Ember does not check relationships when figuring out isDirty.
Here is a solution proposed by someone else (that I do not think solves the problem)