Dropdown selection changed event
<select data-bind="options: choices, value: selectedChoice"></select> <hr /> <select data-bind="event: { change: selectionChanged }"> <option>A</option> <option>B</option> <option>C</option> </select>
var viewModel = { choices: ["one", "two", "three"], selectedChoice: ko.observable("two") , selectionChanged: function(event) { alert("the other selection changed"); } }; viewModel.selectedChoice.subscribe(function(newValue) { alert("the new value is " + newValue); }); ko.applyBindings(viewModel);
出处:http://jsfiddle.net/rniemeyer/LBz6d/

浙公网安备 33010602011771号