I have a select with several options and I try to make some of the options unselectable programmatically. For instance, my code is :
<select>
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
<script>
$('select').selectize();
</script>
My question is: how can I make to get option "2" disabled (i.e. not displaying and not selectable) programmatically? -- I tried this code...
$('select')[0].selectize.$dropdown_content.find('[data-value="2"]').removeAttr('data-selectable');
... but it does not work (when I inspect the DOM I see that option "2" has no 'data-selectable' attribute, but it still renders and is selectable...).
Am I wrong here? And if so: what is the proper way to make an option unselectable (I can't find it anywhere in the doc)?
(I created a jsFiddle here: http://jsfiddle.net/j8YUA/3/)
display
tonone
. – Gerfen