ok so i have the following json:
{"VehicleMakes":
[{"VehicleModels":[],"ID":3,"Description":"BMW"},
{"VehicleModels":[],"ID":1,"Description":"Ford"},
{"VehicleModels":[{"ID":1,"Description":"Astra","MakeID":2},{"ID":2,"Description":"Corsa","MakeID":2}],"ID":2,"Description":"Vauxhall"}],
"VehicleModels":[],
"SelectedMake":"Vauxhall","SelectedModel":null,"Postcode":null}
So basically I have a few vehicle makes and a make can have a number of models.
I then have the following model:
function SearchModel() {
this.SearchCriteria = "";
this.SelectedMake = ko.observable();
this.SelectedModel = ko.observable();
}
And then this html:
<select id="vehiclesMake" data-bind="options: SearchCriteria.VehicleMakes, optionsText: 'Description',optionsValue: 'Description', value: SelectedMake, optionsCaption: 'Choose...'"></select>
<div data-bind="if: SelectedMake">
<select data-bind='options: SelectedMake().VehicleModels, optionsText: "Description", optionsCaption: "Select...", optionsValue: "Description", value: SelectedModel'></select>
</div>
So I am basically trying to say, when a vehicle make is selected in the first dropdown, display its models in the 2nd dropdown.
The first dropdown populates fine and when I make a selection the 2nd dropdown appears but isn't being populated.
Note I assign all the json to the property SearchCriteria.
What am I doing wrong?