I'm using Backbone relational and it's great. The problem I have run into is when I need the backend to provide the url for models to attach to.
This isn't such a problem when using one-to-one relationships because the model can hold onto the url as an attribute of itself.
The collection on the other hand creates a separate model within itself.
What is the best way to bind these together. Examples below
{
"user": {
"url": "http://example.com/api/user/1"
},
"permissions": {
"url": "http://example.com/api/user/1/permissions"
}
}
In the above example, I want user to be a model with the url provided, and the permissions a collection, with the url provided.
What I have tried is to get the collection working is the following:
{
"permissions": {
"url": "https://example.com/api/user/1/permissions"
"data": []
}
}
But I wasn't able to run a parse that extracts the variables out.
If you have not set {parse: true}
on your relation definition (documentation), then you should do so, and see if that fixes your problem. Otherwise, it would help if you provided more code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With