I'm not sure if it's the correct way to express my requirement. But the word "fork" appears in the roadmap of Ember Data github page. And it's a killer feature in EPF. I'm wondering if I can do it in Ember Data.
The fork feature is useful when we have an edit page and bind a model. When we edit the information, I don't want the model properties to be changed because if the model properties are also displayed in other place they will be changed automatically. That's not what I want.
An example is a list on the left side of the page and a edit form for a specific model on the right side of the page. When I modify role name in the text field, the role name on the left side is changed because of data binding.
EPF solves this problem by "fork" the existing model and set it in a child session. The session in EPF is similar with store in Ember Data. When you modify the forked model it does not effect the model in the main session. After the forked model is updated it can be merged back to main session, and the corresponding model in main session are updated.
What I can think a solution in Ember Data is to create a different store and copy the model to that store. But it is a bit complicated. Does anyone have a better solution? I searched on stackoverflow and ember discuss forum and didn't find an answer.
Model.toJSON
into a newEm.Object
instance, and binding the view to this new instance, then when I'm done editing (or whatever action), I'd serialize back to the actual model in store (only updating the properties in the model that were different than the new object). Have you tried something similar to this? – MilkyWayJoeEm.Object
as model. And I copy the model to bind to the editing form. But this solution is not good for Ember Data, because when you want to update a model, you should set properties to this model and callsave
, in this case it'll also modify all other UI that bind the same model, so I can't just use a copiedEm.Object
to do that. – darkbaby123