0

我正在使用引导选择插件(https://silviomoreto.github.io/bootstrap-select/)为我的下拉多选框。取消选择任何其他选项引导程序的默认选择

我已启用默认选项,当页面加载时打勾。图像下方

enter image description here

<select id="dataPicker" class="selectpicker" multiple> 
 
\t <optgroup > 
 
\t \t <option value="default" selected="selected">ALL</option> 
 
\t </optgroup> 
 
\t <optgroup "> 
 
\t \t <option value="failed">FAILED</option> 
 
\t \t <option value="running">RUNNING</option> 
 
\t \t <option value="completed">COMPLETED</option> 
 
\t </optgroup> 
 
</select>

在上面的代码 “ALL” 将被默认地选择。

我正在寻找一种行为,当用户选择“ALL”以外的任何选项时,“ALL”会自动取消选择。

请帮忙。

回答

0

将'data-actions-box =“true”'添加到您选择的元素。

<select class="selectpicker" multiple data-actions-box="true"> 
     <option>Mustard</option> 
     <option>Ketchup</option> 
     <option>Relish</option> 
</select> 

https://silviomoreto.github.io/bootstrap-select/examples/#selectdeselect-all-options

如果你希望通过你的方法继续,那么你将需要添加的选择项事件一个事件挂钩并检查,如果该项目是“全部”项目和手动取消选择列表中的所有项目,反之亦然。

https://silviomoreto.github.io/bootstrap-select/methods/#selectpickerselectall