Currently there is no way to dynamically disable option from js.
This would be nice to have
There is using JQ and the plugin.
First disable the option with jQuery, and then call render on the plugin.
$('#mySelect option[value="3"]').prop('disabled', true);
$('#mySelect').selectpicker('render');
but we could simplify this with one call, something like
$('#mySelect').selectpicker('disable', selector);
We could pass the selector as either a straight value, or array of values...
3 or my value or [1,5,10]
and it could also be a JQ Selector..
[value="3"] or #myID or .MyClass
so something like
$('#mySelect').selectpicker('disable', [1,3,'hello']);
$('#mySelect').selectpicker('disable', '[value="3"]');
$('#mySelect').selectpicker('disable', '.MyOptionClass');
?
We could add it in there...but I think it would just be simpler to just run render again. It seems like it would be less documentation to have to remember - simply add your typical line of jQuery to disable the option and then include $('.selectpicker').selectpicker('render'); right after it. What do others think?
It is more flexible leaving it down to the dev to update the data and then re-render. Im inclined to leave it as is.
Not support disabled attribute, but YES support readonly attribute, then...
$("[id^=yourselector]").prop("readonly", "");
Heyy ! I just want to disable some of the options from the drop down list. How can i do that? Please help ! Thanks in Advance