Answer the question
In order to leave comments, you need to log in
How to properly bind complex objects in vue.js?
Good day to all. I want to ask the experts how you solve a typical task of model binding with nested lists in vue.js.
For example, after a get request to the server, we get a json like this
var data = [{
Id: 0,
Name: "Cfg-1",
Items: [{
Id: 11,
Name: "Item11",
ItemFields: [{
FName: "Field1",
Value: "FV1"
},
{
FName: "Field2",
Value: "FV2"
}]
},
{
Id: 12,
Name: "Item12",
ItemFields: []
},
{
Id: 13,
Name: "Item13",
ItemFields: []
}]
},
{
Id: 1,
Name: "Cfg-2",
Items: [{
Id: 21,
Name: "Item21",
ItemFields: []
},
{
Id: 22,
Name: "Item22",
ItemFields: [{
FName: "Field1",
Value: "FV221"
}]
},
{
Id: 23,
Name: "Item23",
ItemFields:[]
}]
}]
<select id="cfg-list" class="form-control" multiple=""></select>
Answer the question
In order to leave comments, you need to log in
Rebuild the data in such a way that the links refer to one object, changing which, all links will change, or when the object changes, look for it in other places, i.e. manually update, this is if I correctly understood the essence of the issue (1st option is easier and faster to do )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question