Using knockoutjs mapping plugin is it possible to only make the child elements observables?
I have a large amount of data in the format below (400/500 records) the automatic mapping is really slow as its making every fields observable but I only need to make children observable.
How would I manually make only the children fields observable while ignoring others?
Also, what’s the best way to deal with last amount of data? Any server-side paging with knockoutjs code would be great.
Thanks.
{
"name": "John Smith",
"age": 32,
"employed": true,
"address": {
"street": "701 First Ave.",
"city": "Sunnyvale, CA 95125",
"country": "United States"
},
"children": [
{
"name": "Richard",
"age": 7
},
{
"name": "Susan",
"age": 4
},
{
"name": "James",
"age": 3
}
]
}
You don’t have to pass in the whole object into the mapping function, just the parts that you want mapped. Since you want to just map the children array, pass that into the mapper.
Otherwise, you could use the mapping options to specify that you want to copy the other fields over (as opposed to mapping them).