I was messing around learning Knockout and I had an issue dealing with the dropdown bindings. Basically it is a mockup of a patient that can have 1 or more diagnosis codes attached.
If you look at my jsfiddle, I have an object with name/value pairs (axis1items) that holds the select list items. I also have an observablearray holding all the results (patientDiags) which is then serialized into JSON.
When you select an item, the value is set as the axis1items item and it is serialized as:
"DiagnosisID":{"dxname":"(V71.81) Abuse and neglect","dxvalue":549}
I would like the final serialized result to be only the dxvalue:
"DiagnosisID": 549
I assume this can easily be done using a computed value, changing the structure of my viewmodels, or some other knockout specific template keyword that I am overlooking?
In addition: any other suggestions on how to improve my code would be greatly appreciated!