Skip to content

Propagate parse option to nested models #11

@sobrinho

Description

@sobrinho

Example:

Schedule = Backbone.Model.extend({
  parse: function (attributes) {
    attributes.at = moment(attributes.at);

    return attributes;
  }
});

Agenda = Backbone.NestedModel.extend({
  relations: [
    {
      type: "one",
      key: "schedule",
      relatedModel: function () { return Schedule }
    }
  ],

  parse: function (attributes) {
    attributes.created_at = moment(attributes.created_at);

    return attributes;
  }
});

new Agenda(window.agenda, { parse: true });

Agenda.prototype.parse is called but Schedule.prototype.parse don't.

Do you think that makes sense to propagate the options from the higher model to lower models?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions