问题描述
我正在使用引导多选列表框.当用户在多重选择上选择选项时,它会正确显示.但是有一个选项可以重置先前选择的选项.当用户单击重置"按钮时,会自动将style=display:none
添加到下拉按钮,并且下拉列表将变为不可见.
I am using bootstrap multiselect list box. When user selects options on the multiselect it shows correctly. But there is a option to reset the previously selected options. When user click on reset button, automatically style=display:none
is adding to the dropdown button and the dropdown list is becomes invisible.
这是我的代码
$("#button").click(function () {
$('option', $('.multiselect')).each(function (element) {
$(this).removeAttr('selected').prop('selected', false);
});
$('.multiselect').multiselect('refresh');
});
推荐答案
其他有用的选项是:
-
$('Id').multiselect('refresh');
-根据选择的所选选项刷新多选.
$('Id').multiselect('refresh');
- Refreshs the multiselect based on the selected options of the select.
$('Id').multiselect('destroy');
-取消绑定整个插件.
$('Id').multiselect('destroy');
- Unbinds the whole plugin.
buildFilter
:构建过滤器.
buildSelectAll
:构建全部selct.检查是否已创建全选.
buildSelectAll
: Build the selct all.Checks if a select all has already been created.
$('Id').multiselect('select', ['1', '2', '4']);
-选择给定值的所有选项.
$('Id').multiselect('select', ['1', '2', '4']);
- Select all options of the given values.
clearSelection
:清除所有选中的项目.
clearSelection
: Clears all selected items.
$('Id').multiselect('deselect', ['1', '2', '4']);
-取消选择给定值的所有选项.
$('Id').multiselect('deselect', ['1', '2', '4']);
- Deselects all options of the given values.
$('Id').multiselect('selectAll', true);
-选择所有启用的&可见的选项.
$('Id').multiselect('selectAll', true);
- Selects all enabled & visible options.
$('Id').multiselect('deselectAll', true);
-取消选择所有选项.
$('Id').multiselect('deselectAll', true);
- Deselects all options.
$('Id').multiselect('rebuild');
-重建插件.
$('Id').multiselect('enable');
-启用多选.
$('Id').multiselect('disable');
-禁用多选.
hasSelectAll
:检查是否存在全选复选框.
hasSelectAll
: Checks whether a select all checkbox is present.
updateSelectAll
:根据当前显示和选定的复选框更新全选"复选框.
updateSelectAll
: Updates the select all checkbox based on the currently displayed and selected checkboxes.
$('Id').multiselect('updateButtonText');
-根据当前选择的选项更新按钮文本及其标题.
$('Id').multiselect('updateButtonText');
- Update the button text and its title based on the currently selected options.
getSelected()
:获取所有选定的选项.
getSelected()
: Get all selected options.
getOptionByValue()
:根据其值获取选择选项.
getOptionByValue()
: Gets a select option by its value.
$('Id').multiselect('dataprovider', options);
-提供的数据将用于构建下拉列表.
$('Id').multiselect('dataprovider', options);
- The provided data will be used to build the dropdown.
有关更多详细信息,请访问 bootstrap-multiselect
for more detail visit bootstrap-multiselect
这篇关于bootstrap multiselect(刷新)无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!