I'm having a bit of trouble getting my head around a problem I'm having.
What I'd like to do is, when typing in a textbox, to check if the checkbox in the same row is clicked or not.
Could anybody point me in the right direction please?
Thanks, John
I'm having a bit of trouble getting my head around a problem I'm having.
What I'd like to do is, when typing in a textbox, to check if the checkbox in the same row is clicked or not.
Could anybody point me in the right direction please?
Thanks, John
使用subscribe和valueUpdate(在按下键而不是模糊时触发事件)
var row = function (check, value) {
this.selected = ko.observable(check);
this.word = ko.observable(value);
this.word.subscribe(function (value) {
if (this.selected()) {
alert("checked");
}
}.bind(this));
};
var viewModel = {
rows: ko.observableArray([new row(false, 'a'), new row(true, 'b'), new row(false, 'c')])
};
ko.applyBindings(viewModel);
HTML 文本框绑定:
<input type="text" data-bind="value: word, valueUpdate: 'afterkeydown'" />