我希望能夠在選擇元素上應用淘汰賽結合selectOrDie
以統一應用selectOrDie。將淘汰賽結合與selectOrDie結合使用
ko.bindingHandlers.selectOrDie = {
init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
// This will be called when the binding is first applied to an element
// Set up any initial state, event handlers, etc. here
$(element).selectOrDie({
onChange: function() {
console.log(element);
}
});
},
update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
// This will be called once when the binding is first applied to an element,
// and again whenever any observables/computeds that are accessed change
// Update the DOM element based on the supplied values here.
console.log($(element).siblings('span .sod_label').text());
}
};
我不知道如何設置它,以selectOrDie註冊的更改觸發綁定更新。還是有更好的方法?
這是選擇的元素,有什麼特別的:
<select data-bind="selectOrDie: $data" data-custom-class="w60">
<option>10</option>
<option>20</option>
<option>30</option>
<option>50</option>
<option>Alle</option>
</select>
我怎樣才能讓一個淘汰賽綁定一般適用selectOrDie的元素?