当您使用search feature
,然后使用select_all
它时,它不能一起使用,它会选择“一切”,就好像搜索没有改变一样,但搜索本身会“隐藏”元素。它应该只选择所有项目visible
想知道其他人是否遇到过这个问题或知道解决方案。如果有人可以提供帮助,再次感谢!
使用jQuery MultiSelect 插件: http: //loudev.com
这是我目前正在使用的代码,搜索利用了quicksearch
js
$('.multiSelect').multiSelect({
selectableHeader: "<div><a href='#' id='select-all'>select all</a></div><input type='text' class='search-input form-control' autocomplete='off' placeholder='search' style='margin-bottom:5px'>",
selectionHeader: "<div><a href='#' id='deselect-all'>deselect all</a></div><input type='text' class='search-input form-control' autocomplete='off' placeholder='search' style='margin-bottom:5px'>",
afterInit: function(ms){
var that = this,
$selectableSearch = that.$selectableUl.prev(),
$selectionSearch = that.$selectionUl.prev(),
selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
.on('keydown', function(e){
if (e.which === 40){
that.$selectableUl.focus();
return false;
}
});
that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
.on('keydown', function(e){
if (e.which == 40){
that.$selectionUl.focus();
return false;
}
});
},
afterSelect: function(){
this.qs1.cache();
this.qs2.cache();
},
afterDeselect: function(){
this.qs1.cache();
this.qs2.cache();
}
});
$('#select-all').on('click',function(){
$('.multiSelect').multiSelect('select_all');
return false;
});
$('#deselect-all').on('click',function(){
$('.multiSelect').multiSelect('deselect_all');
return false;
});
jsfiddle 演示:http: //jsfiddle.net/b8ygzqca/6/