Ember Data behavior of isDirty in parent record when embedded child record is modified


In Ember Data, when a parent record has embedded child records, the parent record is not marked as ‘isDirty’ when a child record is modified or deleted. An example I came up with is http://jsfiddle.net/ahecht/LHgq2/, where modifying or removing the embedded child record doesn’t change the isDirty state on the parent record. Since the load and save take place with the parent record, why is it that the isDirty state on the parent record doesn’t reflect the status of the embedded child record? There is a workaround where I can create a computed property that takes into account child records, but it seems like a common enough use case that Ember Data would handle it.


Currently only changes to attributes (DS.attr properties) affect the dirty state of a record. See this github comment for the official-ish stance on this issue. It does seem to be a common use case (simply judging from the number of github issues/comments about it), but I think you’d be surprised at how complex a problem it really is. It’s rife with edge cases and gotchas, many of which are related to the distinction between the two different kinds of ‘embedded’ records.

My understanding/hope is that ED has sidestepped the issue for the moment until there’s been enough community feedback to converge on the precise semantics of relationship dependencies. In the meantime I’ve explored the problem in a rough plugin that may suit your needs.