So in the end I would like either the Car or Truck VehicleViewModel to be in the selectedVehicleGroup observable.
javascript
data-binding
radio-button
knockout.js
Share
Improve this question
edited Apr 6, 2012 at 13:37KodeKreachor
asked Apr 6, 2012 at 13:31
KodeKreachorKodeKreachor8,8921010 gold badges4949 silver badges6464 bronze badges
Add a ment
|
3 Answers
3
Reset to default
3
As documented here
only Select nodes have the ability to bind an arbitrary JavaScript object to a value. Other inputs require a string value, which is why your value is returning "[Object object]".
You can still do what you want but you will have to manually map a key and find the appropriate object yourself. Here is a fiddle that demonstrates:
http://jsfiddle/jearles/JcPXy/
FYI for other readers ing to the accepted answer, KO v3 added the checkedValue binding which now makes this possible.
I needed this too. My solution was similar to John Earles except I used a puted instead of subscribe: