Been working on upgrading an app from EAK 1.7.1 to ember-cli 1.11.3, and ember-data from beta11 to beta16.1, and while it’s been an enormous two week ordeal, I’ve finally gotten the app ported over (ember-cli is such a huge improvement over EAK btw, great work!)
However, I’ve got one remaining issue, and I just can’t seem to figure out how to fix it. I have a view in my app that displays a parent model, along with it’s children, using each child in model.children. On this page, you can edit data fields on the parent, or on the children, but you cannot add or remove children.
The strange thing is in the new version of ember/data, for some reason, whenever I save the parent, it appears to be invalidating the entire child_ids array. This results in the entire each child in model.children block being completely re-rendered (the child views have new ember IDs), and thus any state / in progress editing on the children is lost.
This doesn’t make any sense to me, as no children were added or removed (or even modified), and thus the child_ids should remain the same. Furthermore, this appears to be a total regression on the old behavior, which handled it correctly.
Here’s 2 jsbins to make my issue clearer:
ember 1.7.1 (old, correct behavior):
ember 1.11.3 (new, incorrect behavior)
On both of these, first click “parent 1” to load the parent model, with the 3 child models rendered below it. Click on any or all children to expand them. Now, click “click here to save” to simulate saving the parent model - you’ll notice on the old version of ember, the children are correctly left alone and not re-rendered (as they haven’t changed). However, on the new version, all the expanded children will collapse, and in fact inspecting the elements in firebug will show that the ember-ids are changed, as the whole block is being re-rendered.
Furthermore, while in my app there is no way to add or remove children from this page, you can simulate this behavior as well - if you modify the $.mockajx({} block on the jsbin, and set the response to be child_ids:[1, 3] instead - on the old version, this behaves absolutely as expected - child 1 and child 3 are left alone (whether in their expanded or unexpanded state), and child 2 is removed.
On the new version, again, the entire block is being redrawn.
Am I doing something wrong here? I feel like logically this is a regression, though I’m sure there’s a reason for the change. Anyone have any suggestions for a workaround? I’ve tried using components, views, render, and partials for the children, but all of them exhibit the same issue - the problem is with the parent.child_ids property forcing the entire each block to redraw rather than only added, removed, or modified entries.
Any suggestions for how to proceed / workaround this?
*edit: updated old version jsfiddle to work in chrome