我正在尝试使用BsMultiSelect。
如何手动启用/禁用选择菜单?
我能够像这样成功地禁用菜单
// remove all options
removeOptions(select);
// disable the select element
select.setAttribute('disabled', true);
// update the data since all options were removed
select.updateData();
// update the appearance of the menu since it is now disabled
select.updateAppearance();然后我试着让它变成这样,但它不起作用。
// add new options to the select element
addOptions(select);
// enable the select element
select.removeAttribute('disabled');
// update the data since new options were added
select.updateData();
// update the appearance of the menu since it is now enabled
select.updateAppearance();发布于 2022-01-15 15:16:59
有点晚了,但我遇到了同样的问题,并通过来自bsMultiSelect的内建选项bsMultiSelect解决了这个问题,它需要真或假。
然后,我使用$('#yourMultiSelectOption').attr('custom-data-attr', false/true).bsMultiSelect("UpdateDisabled")首先将属性更改为所需的选项,然后手动触发bsMultiSelect的更新。
$(#yourMultiSelectOption).bsMultiSelect({
getDisabled: function () {
return $("#yourMultiSelectOption").attr('custom-data-attr') === 'true';
},
[other options...]
})
https://stackoverflow.com/questions/69408465
复制相似问题