I am trying to use BsMultiSelect.
How can I manually enable/disable a select menu?
I was able to successfully disable the menu like so
// 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();
Then I tried to enable it like this which did not work
// 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();
A bit late, but I had an identical problem and solved it by the build-in option getDisabled from bsMultiSelect, which requires either true or false.
I then used $('#yourMultiSelectOption').attr('custom-data-attr', false/true).bsMultiSelect("UpdateDisabled") to first change the attribute to the desired option and then manually trigger an update of the bsMultiSelect.
$(#yourMultiSelectOption).bsMultiSelect({
getDisabled: function () {
return $("#yourMultiSelectOption").attr('custom-data-attr') === 'true';
},
[other options...]
})