Comments (6)
Hi folks, any idea how to perform this?
from ampersand-rest-collection.
@e2jk, can you post your model definition and example form data?
from ampersand-rest-collection.
The model definition: http://pastebin.com/iMkFb3TG
When posting information on the page to create a new record, the following data is posted from the form:
{"abbreviation":"Test Object","objectType":"Interface","description":null,"notes":null,"fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"abbreviation":"","name":""},"fromSystem":{"systemName":"","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"toSystem":{"systemName":"","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"responsiblePerson":{"firstName":"","lastName":""}}
As you can see, all the data from the children is empty.
Since I'm saving again the model after it has just been created (again, with the same data from the form), a PUT command is issued just after that, which has all the children item populated:
{"id":13,"abbreviation":"Test Object","objectType":"Conversion","description":null,"notes":null,"fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"id":2,"abbreviation":"ENC","name":"Afspraak en Opname","objects":[4,5,6,7,8]},"fromSystem":{"id":9,"systemName":"SchedulePlus","vendorName":"","contactName":"","contactPhone":"","contactEmail":"","fromObjects":[]},"toSystem":{"id":11,"systemName":"New EPD","vendorName":"EPD vendor","contactName":"Toto van der Been","contactPhone":"9898989898","contactEmail":"[email protected]","fromObjects":[10],"toObjects":[7]},"responsiblePerson":{"id":5,"firstName":"Rob","lastName":"van Egmond"}}
I've added a debug console log just after submitCallback
, and the JS object that is the data
variable does have properties named as the children, which are themselves objects that contain the data. Example from this Firefox web tools screenshot:
from ampersand-rest-collection.
This is the text version of the screenshot (with another object I've just created). It's the output of console.log(JSON.stringify(data));
just after submitCallback
is called.
You'll notice that the children data are sent themselves as objects (e.g. embedded objects). And as mentioned, when calling model.save
with the same data
in the success callback of app.objects.create
, the model is properly saved (i.e. the issue is not in data
, but likely in the way children are saved when calling collection.create
whereas model.save
works flawlessly):
19:30:17,492 "{"abbreviation":"XXX","objectType":"Conversion","description":"This is a test","notes":"These are notes","fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"id":2,"abbreviation":"ENC","name":"Afspraak en Opname","objects":[4,5,6,7,8]},"fromSystem":{"id":2,"systemName":"Radiologix","vendorName":"Radiologix","contactName":"David Seller","contactPhone":"123456789","contactEmail":"[email protected]"},"toSystem":{"id":3,"systemName":"PharmaPill","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"responsiblePerson":{"id":2,"firstName":"Marcel","lastName":"Eiffel","objects":[3,9,10]}}"1 project-de-brug.nonCached.js:911:1
from ampersand-rest-collection.
Hi there, any thoughts about this issue?
from ampersand-rest-collection.
I couldn't understand from your pastepin what you are trying to do. Try to create a minimal example that doesn't work. I sense that you may be mixing between children
and collections
.
from ampersand-rest-collection.
Related Issues (16)
- Needs way more tape tests HOT 3
- Fetching a model by id when model is dynamic HOT 2
- Sync entire collection with server-side HOT 4
- fetchById should take secondary [xhr] options object HOT 3
- Preprocess XHR response
- rest-mixin should probably be it's own module HOT 4
- consider lodash-mixin HOT 6
- Make type to POST
- length-property HOT 6
- Update to latest ampersand-collection-rest-mixin
- constructor/initialize - suggestion
- How to handle header "Access-Control-Allow-Origin" for CORS
- how can I use fetch() method HOT 1
- params passed to ajaxConfig are undefined HOT 3
- Issues when destroying multiple models from an ampersand-rest-collection HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ampersand-rest-collection.