Only one select2 dropdown is getting enable = false

43 Views Asked by At

I have three select2 dropdown. I am disabling them like this:-

$('#rescues').val([]).select2('enable', false).trigger('change')
$('#first_aids').val([]).select2('enable', false).trigger('change')
$('#extinctions').val([]).select2('enable', false).trigger('change')

However, only the first one is getting disabled.

enter image description here

If I don't disable the first one (rescues) but the second one (first_aids), then only the second one is getting disabled, not the third one:-

//$('#rescues').val([]).select2('enable', false).trigger('change')
$('#first_aids').val([]).select2('enable', false).trigger('change')
$('#extinctions').val([]).select2('enable', false).trigger('change')

enter image description here

Seems like once one select2 is getting disabled, other's aren't disabled.

How can I fix this?

1

There are 1 best solutions below

1
Yuvaraj M On

Just use line-terminatior ;

$('#rescues').val([]).select2('enable', false).trigger('change');
$('#first_aids').val([]).select2('enable', false).trigger('change');
$('#extinctions').val([]).select2('enable', false).trigger('change');