Skip to content

Fixed $.Model.restore(true) overwriting associated (nested) models with plain objects#82

Closed
marnusw wants to merge 1 commit intojupiterjs:masterfrom
marnusw:nested_model_restore
Closed

Fixed $.Model.restore(true) overwriting associated (nested) models with plain objects#82
marnusw wants to merge 1 commit intojupiterjs:masterfrom
marnusw:nested_model_restore

Conversation

@marnusw
Copy link
Contributor

@marnusw marnusw commented Oct 19, 2011

Currently when backup/restore is used to restore a model with the restoreAssociations option the nested model is lost because it is overwritten by the plain object from the store. I propose checking whether the current property is a nested model and in that case setting its values with its own attrs() method. This preserves the nested model and also causes it to trigger the appropriate update events etc.

Two things though:

  • I'm not sure whether it's OK to return early after setting the nested model values, but it seems to me that the nested model will handle everything that's necessary.
  • There may be a better way to test whether a property is a nested model.

…updates the property using its own .attrs() method.
@marnusw marnusw closed this Jan 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant