我希望能够设置淘汰赛的价值,observable
即value
a select
with case-insensitivity
。因此,在我下面的示例中,传递justin
将设置selectedValue
为Justin
.
不工作:jsfiddle
工作:jsfiddle
HTML
<select id="people" data-bind="options: peopleList, value: selectedPerson, optionsCaption: 'Choose...'">
</select>
JS
function MyViewModel(defaultPerson) {
var self = this;
self.selectedPerson = ko.observable(defaultPerson);
self.peopleList = ko.observableArray(["Justin", "Sam", "Chris", "John"]);
}
$(function(){
var person = 'justin';
var viewModel = new MyViewModel(person);
ko.applyBindings(viewModel);
});