In a related question I wanted to know How to add parent object to child in a one-to-many relationship in ember.js. Now I want to know how to simultaneously save them on the server when creating or updating the parent with a newly created child.
The server would expect something like this:
parent {
prop1: 'val1',
prop2: 'val2',
child: {
prop1: val1
prop2: val2
}
}
but ember's payload looks like this:
parent {
prop1: 'val1',
prop2: 'val2',
child:null
}
The same goes for updates when having an already existing child appended to the parent. Then the payload looks something like this:
parent {
prop1: 'val1',
prop2: 'val2',
child:2
}
So it's not the child-object transferred with the payload but only it's id if existing (otherwise null)). Is it possible to send a nested object like the server expects or do I have to save both models separately with two ajax-post/put-requests.?
Aucun commentaire:
Enregistrer un commentaire