0
votes

i have a select element and this element option data bind by knockout viewmodel,

<select class="tournamentSelect filterCombo" data-bind="options: viewModel.tournamentList, optionsText: 'Name',optionsValue: 'Id'"></select>

And on document ready my "change" method trigger because of select binding.

 $(function () {    

    $(".filterCombo").change(function () {       
        filterx();
    }); 
});

Is there anyway for ignore to trigger select element change method ?

2

2 Answers

0
votes

Try

$(function () {    
    var i = 0 ;
    $(".filterCombo").change(function () {       
        if(i++ > 0)  filterx();
    }); 
});
0
votes

Put option caption as

<select class="tournamentSelect filterCombo" data-bind="options: viewModel.tournamentList, optionsText: 'Name',optionsValue: 'Id',optionsCaption: 'Choose...'"></select>

It should work