What I need is, that if the user selects the option with value 0 disable an entire group in the select, or if i can´t use groups disable all the options i want, it´s possible?
i have try it like this:
$('#ottipo_alcance').chosen().change(function(event){
if (this.value == '0')
$('optgroup option').prop('disabled', true);
else
$('optgroup option').prop('disabled', false);
$('#ottipo_alcance').trigger("liszt:updated");
});
<select id="ottipo_alcance" name="ottipo_alcance[]" class="chosen" style="width:200px" multiple="true">
<option value="0">General</option>
<optgroup label="Áreas">
<option value="1">Sistemas</option>
<option value="2">Operaciones</option>
...
</optgroup>
</select>
NOTE: I also tried with $('#ottipo_alcance').trigger("chosen:updated");
You should be able to disable an entire optgroup by using:
$('#ottipo_alcance').find('optgroup:first').prop('disabled', true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With