javascript - jQuery MultiSelect can not enable a disabled -
i have several dropdowns, 1 of them enabled beginning on, others disabled <select class="someclass" name="somename" multiple id="someid" disabled>
the enabling of disabled drop-downs depends on selection of values in first (enabled) dropdown, use following code
$('#enableddropdown').on('change',function() { }
in there (in further if statement) tried every possible combinations of:
$('#someid').multiselect('enable'); $('#someid').multiselect('refresh'); $('#someid option').attr('disabled',false); $('#someid').prop('disabled', false); $('#someid').material_select(); $('#someid').removeattr('disabled');
but not works. dropdown remains disabled!
edit: have $(document).ready(function () { }
following...
$('#someid').multiselect({ name : 'somename', columns : somenumber, placeholder : 'someplaceholder' });
this seems cause problem, because if remove corresponding code block in document.ready function drop-down behaves expected. problem need document.ready function.
i dont understand why interacts because document.ready executed once when side loads. enabling happens after that.
check condition once again. prop('disable',false)
should work, check below snippet reference.
$(document).ready(function() { $("#checkme").click(function() { if ($(this).is(":checked")) { $("#dropdown").prop("disabled", true); } else { $("#dropdown").prop("disabled", false); } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <select id="dropdown" style="width:200px;"> <option value="feedback">options</option> <option value="feedback">options</option> </select> <input type="checkbox" id="checkme" value="feedback"/>check me!
Comments
Post a Comment