Skip to content

Hydrating views from nested models or collections #263

@lo1tuma

Description

@lo1tuma

Given the following nested structure which we get from a single REST endpoint (GET /groups):

  • groups collection
    • group model
      • items collection
        • item model

we would like to render a couple of nested views which works perfectly on the server. But hydrating the nested views on the client fails with undefined item models in the item view. The nested items are contained in the bootstrappedData but hydrate seems not to take into account how data is passed through nested views.

We transform the items array from the result to a rendr collection by overwriting parse:

GroupModel.prototype.parse = function (result) {
  result.items = new Items(result.items, {app: this.app});
  return result;
};

@spikebrehm what do you think about this issue? Would you accept a PR?

cc: @zeussolo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions