Backbone Model.save does not transfer model state to a nested object

Backbone Model.save does not transfer model state to a nested object. This is normal?

A typical Rails script is something like this [: product] parameter. How could I achieve this?

+6
source share
1 answer

This was mentioned earlier: Saving nested objects using Rails, backbone.js and accepts_nested_attributes_for

I would suggest overriding JSON on the base model.

toJSON: function(){ json = {car : this.attributes}; return _.extend(json, {engine_attributes: this.get("engine").toJSON()); } 

toJSON is called inside the synchronization method immediately before sending data to the server.

+12
source

Source: https://habr.com/ru/post/888620/


All Articles