Reputation: 302
I am trying to enable and disable Selectize Dropdown depending on Checkbox value. I wrote something that only works for disabling the control. But I cant enable it.
Here is what I tried:
It shows this error:
if I comment out $('#' + Id)[0].selectize.enable();
this line then disabled functionality works just fine.
Is a work-around available?
Upvotes: 0
Views: 307
Reputation: 302
I had to check if $('#' + Id)[0].selectize
has value or not. This solved my issue. Here is full snippet for everyone:
function EnableDisablePicker(Instrution, Id) {
if (Instrution === 'Disable') {
if ($('#' + Id)[0].selectize) {
$('#' + Id)[0].selectize.disable();
}
}
if (Instrution === 'Enable') {
if ($('#' + Id)[0].selectize) {
$('#' + Id)[0].selectize.enable();
$('#' + Id)[0].selectize.clear();
}
}
}
Upvotes: 0