I have a checkbox list with the following values:
"AllAuctionTypes": [
{
"AuctionTypeID": "e42fde21-807c-4c81-938d-1918ca13f28b",
"AuctionTypeName": "Truck & Trailer",
"AuctionID": "00000000-0000-0000-0000-000000000000"
},
{
"AuctionTypeID": "eb1cc1c2-d08d-45b6-8c46-1dbd9d54bd35",
"AuctionTypeName": "Agriculture",
"AuctionID": "00000000-0000-0000-0000-000000000000"
},
{
"AuctionTypeID": "edb81092-0bfc-462e-a50e-4510feb54c55",
"AuctionTypeName": "Plant & Machinery",
"AuctionID": "00000000-0000-0000-0000-000000000000"
}
]
I want to data-bind the checked value from data that I obtain from my server. Which looks like this:
{
"AuctionID": "88848ed7-c2bd-4428-9c4c-c524f2717051",
"AuctionName": "Another Auction",
"AuctionDate": "2015-04-22",
"AuctionTime": "16:50:00",
"AuctionLocation": "LolVille",
"AuctionContactPerson": "Bill",
"AuctionContactNumber": "0115552222",
"AuctionEMail": "[email protected]",
"AuctionWebsite": "http://somesite.co.za",
"AuctionType": [
{
"AuctionTypeID": "e42fde21-807c-4c81-938d-1918ca13f28b",
"AuctionTypeName": "Truck & Trailer",
"AuctionID": "00000000-0000-0000-0000-000000000000"
},
{
"AuctionTypeID": "edb81092-0bfc-462e-a50e-4510feb54c55",
"AuctionTypeName": "Plant & Machinery",
"AuctionID": "00000000-0000-0000-0000-000000000000"
}
]
}
The AuctionType value(s) are the items that should be marked as selected, but it does not seem to do the binding. Here is my HTML with the bindings:
<div class="form-group">
<label>Auction Catagory</label>
<div>
<table data-bind="foreach: AllAuctionTypes">
<tr>
@*Debugging*@
<td data-bind="text: ko.toJSON($parent.Auction.AuctionType)"></td>
<td>
@*this is the segment I am trying to bind*@
<input type="checkbox" data-bind="checkedValue: $data, checked: $parent.Auction.AuctionType" /> <span data-bind="text: AuctionTypeName"></span>
</td>
</tr>
</table>
</div>
</div>
But it doesn't seem to bind the values based on what was selected, or I am just binding it incorrectly.
Here is a screen cap of the screen showing the debugging segment and the unchecked boxes
Any help will be greatly appreciated!
checkedbinding? I see in the knockout docs that thecheckedbinding behaves loosely when applied to checkboxes and bound to non-boolean values.