The data from eventschemas is not binding even though I can see it in the browser.. This can be seen in the $data value that I provide at the bottom.. Please note that this is a very minimal repro of the problem and the schema can not be changed..
My html:
<div data-bind="with: g">
<div><input type="text" class="form-control" data-bind="value: gname" /></div>
<div>
<table>
<tbody>
<tr data-bind="with:gdetails">
<td>
<select data-bind="options: eventschemas, optionsText: 'schema', value:eventschemacondition.schema"></select>
</td>
</tr>
</tbody>
</table>
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>
</div>
</div>
My javascript:
<script type="text/javascript">
var eventschemas = [{ "schema": "Test"}, { "schema": "Another Test" }];
var AppScope = function () {
function EventSchemaCondition(data) {
this.schema = ko.observable(data.schema);
};
function Gdetails(data) {
this.eventschemacondition = ko.observable(data.eventschemacondition);
};
function G(data) {
this.gname = ko.observable(data.gname);
this.gdetails = ko.observable(data.gdetails);
};
function GsViewModel() {
var self = this;
self.g = ko.observable(new G({ gname: "", gdetails: new Gdetails({ eventschemacondition:new EventSchemaCondition({ schema: "" }) }) }));
}
ko.applyBindings(new GsViewModel());
}();
</script>
This is how my $data looks:
{
"gname": "tttt",
"gdetails": {
"eventschemacondition": {
"schema": ""
}
}
}
As you can see the 'schema' in 'eventschemacondition' is empty even though I can see values in the dropdownlistbox on browser..
Would sincerely appreciate any help
Thanks