KO_click

by nyothecat

HTML

<div id="koRoot">
    <input type='text' data-bind='value: b'/>
    <input type='text' data-bind='value: c'/>
    <button data-bind="click: clickEvent" value="1">Click me!</button>
</div>

JavaScript

var a = ko.observable({
    b: ko.observable("test1"),
    c: ko.observable("test2"),
    clickEvent: function (data, event) { alert(event.target.value); }
});

ko.applyBindings(a, document.getElementById("koRoot"));