I have the following:
<tbody data-bind="foreach: { data: MenuItems, as: 'tableitem' }">
<tr>
<td data-bind="html: tableitem.label"></td>
<td>
<select class="form-control" data-bind="options: $root.GroupedScorecardTypes,
optionsText: 'Name', optionsValue: 'Id', value: tableitem.clean"></select>
</td>
<td>
<select class="form-control" data-bind="options: $root.GroupedScorecardTypes,
optionsText: 'Name', optionsValue: 'Id', value: tableitem.copy"></select>
</td>
</tr>
</tbody>
Which displays the following:
There are three options on the drop downs for each of them. They are : All data,Target Data and Ignore . Now when a user clicks on either All data or Target Data on the populate target column, the Clean target column for that row should change to Target Data.
I tried the following but it didnt seem to work:
self.MenuItems().forEach(function(data){
if (data.copy == 2 || data.copy == 1){
data.clean == 2
}
console.table(data);
});
I need it to change instantly, any idea how i can do this? My data looks like this:
var data = unique.map(function (item) {
return {
'label': item,
'clean': DefaultItem,
'copy': DefaultItem
};
});
if (self.isSaved !== 1) {
self.MenuItems(data);
}
I think you can take advantage of subscribing to an observable. something like the following.