I understand how to disable the entire selectmenu.
But I just want to disable a few of the options within it. How can I do it..?
I understand how to disable the entire selectmenu.
But I just want to disable a few of the options within it. How can I do it..?
The documentation reads:
(emphasis mine).
Which means you can simply add the
disabled
attribute to the<option>
's you want to disable in the HTML and it'll be reflected in the widget once it is initialized.Regarding the the changes you make dynamically to the original
<select>
element, it will not be reflected immediately in the widget - because as one can possibly imagine, constantly querying theDOM
for changes in the original<select>
is likely to cause a performance hit.Hence we have the following:
refresh
All we have to do is, make the changes to original
<select>
and call refresh.In this case, we should target the options to disable using corresponding selectors, disable them using
attr()
and then call refresh, as shown below: