I've three elements: selectbox, checkbox, input.
viewModel.listTest= [{ value: '1', name: '10' }, { value: '2', name: '20' }];
<select class="form-control" data-bind="options: listTest, value: TestSelectBox, optionsText: 'name', optionsValue: 'value', disable: TestTrigger()"></select>
viewModel.TestTrigger= ko.observable(false);
<input id="TestTrigger" type="checkbox" name="TestTrigger" data-bind="checked: TestTrigger" />
viewModel.inputTest = ko.observable('1');
<input name="inputTest " data-bind="value: inputTest , enable: TestTrigger(), valueUpdate: 'afterkeydown'" />
and I want to make: if checkbox is checked the value from input should pass to
viewModel.testValue
otherwise the value from select box should be pass to
viewModel.testValue
How can I do this ? I think I can use knockout method subscribe on checkbox
Aucun commentaire:
Enregistrer un commentaire