我有一个select元素,这个元素选项数据由knockout viewmodel
绑定<select class="tournamentSelect filterCombo" data-bind="options: viewModel.tournamentList, optionsText: 'Name',optionsValue: 'Id'"></select>
在文档就绪时,由于select绑定,我的“更改”方法会触发。
$(function () {
$(".filterCombo").change(function () {
filterx();
});
});
无论如何忽略触发选择元素更改方法?
答案 0 :(得分:0)
尝试
$(function () {
var i = 0 ;
$(".filterCombo").change(function () {
if(i++ > 0) filterx();
});
});
答案 1 :(得分:0)
将选项标题设为
<select class="tournamentSelect filterCombo" data-bind="options: viewModel.tournamentList, optionsText: 'Name',optionsValue: 'Id',optionsCaption: 'Choose...'"></select>
应该有效