0

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

4

1 回答 1

0

例子

使用subscribevalueUpdate(在按下键而不是模糊时触发事件)

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'" />
于 2013-04-08T16:08:24.603 回答