multi-select
multi-select copied to clipboard
multiselect with quicksearch plugin, must click item once and then can work well
selectableHeader: "<input type='text' id='search_input' class='search-input form-control' autocomplete='on' placeholder='search'>",
afterSelect: function(values) {
selected_hosts.push(values[0]);
this.qs1.cache();
},
afterDeselect: function(values) {
selected_hosts.remove(values[0]);
this.qs1.cache();
},
afterInit: function(ms) {
init_hosts();
var that = this,
$selectableSearch = that.$selectableUl.prev(),
selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString).on('keydown', function(e){
if(e.which === 40){
that.$selectableUl.focus();
return false;
}
});
}
$('#xxx').multiSelect(), option parameter is these but i must click the item once and then the search function can work well .
I met the same problem, I found that the reason is that we init the multi-select plugin first and then using 'addOption' to add the options. But I am still thinking of how to fix this.
I got the solution, after "addOption", use $('#xxx').multiSelect('refresh') can fix this problem.