Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify getBootstrappedData to check properties for more models and collections #372

Merged
merged 3 commits into from
Jun 21, 2014
Merged

Modify getBootstrappedData to check properties for more models and collections #372

merged 3 commits into from
Jun 21, 2014

Conversation

saponifi3d
Copy link
Contributor

Running into an issue where a model which contains nested models doesn't correctly get passed from the server to the client.

This PR makes it so we can use the parse function to build out models and then still have bootstrapData hydrate the view.

usage:

// ... in some model ...
parse: function (data) {
  if (_.isObject(data.subModel)) {
   data.subModel = this.app.modelUtils.getModel('SubModel', data.subModel, { app: this.app });
  }
  return data;
}

Then this subModel will be added to the bootstrapData correctly, putting both the Model and SubModel into modelStore in the hydration step... making view "subModelView" model=subModel work in the template to correctly get the data for a subview.

This is a fix for: #263

@coveralls
Copy link

Coverage Status

Coverage increased (+0.11%) when pulling 1c9faae on saponifi3d:bootstrapData-recursive into e1885e6 on rendrjs:master.

@letitia
Copy link

letitia commented Jun 11, 2014

This would be really helpful for our project.

@@ -107,5 +107,27 @@ describe('ViewEngine', function() {

data.should.deep.equal({});
});

it('should create a flat bootstrap object if a model has a nested model', function () {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for writing a test.

@lo1tuma
Copy link
Member

lo1tuma commented Jun 19, 2014

Does this fix #263?

@saponifi3d saponifi3d changed the title Modify getBootstrappedData to check properties for more models Modify getBootstrappedData to check properties for more models and collections Jun 19, 2014
@coveralls
Copy link

Coverage Status

Coverage increased (+0.11%) when pulling 6d87934 on saponifi3d:bootstrapData-recursive into 4dd5051 on rendrjs:master.

saponifi3d added a commit that referenced this pull request Jun 21, 2014
Modify getBootstrappedData to check properties for more models and collections

fixes #263
@saponifi3d saponifi3d merged commit 6497522 into rendrjs:master Jun 21, 2014
@saponifi3d saponifi3d deleted the bootstrapData-recursive branch June 21, 2014 00:21
mdimas added a commit to change/rendr that referenced this pull request Aug 1, 2014
…recursive"

This reverts commit 6497522, reversing
changes made to 4dd5051.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants