multi-select
multi-select copied to clipboard
Disable Element via JavaScript
Hi,
how is it possible to disable an selectbox via javascript? If I trigger a $('#includedUsers').attr('disabled', 'disabled'); or document.getElementById("includedUsers").disabled = true nothing happens with the multi selectbox. But if i check the status of the element via the JS console the disabled="disabled" flag is set but nothing really happens.
Greetings Alex
I can see two ways to do this:
- Disable all options in the menu
$('.ms-elem-selectable').addClass('disabled')
- Recreate it.
$('#includedUsers').attr('disabled', true);
on the element withmultiSelect
bound to it and then destroying it with$('ms-includedUsers').remove();
$('#includedUsers').removeData('multiselect')
and when you recreate it with$('#includedUsers').multiSelect()
it'll be disabled.
Hi @campino-rocks,
First of all let me apologize for the late response.
Since I have fixed the refresh
method, you should do seomething like this:
$('#includeUsers').prop('disabled', true);
$('#includeUsers').multiSelect('refresh');
Let me knows if this solution works for you.
In the mean time I will think about the feature of disabling option without having to refresh the entire multiSelect.
Hi @lou ,
no problem, today I got time to try your proposal, and it works like a charm. The only point what is a bit "not so nice" is, when I disable a selector then i don't see which elements were selected.
Greetings Alexander
Thanks for the report. Concerning the disabled and selected option bug, it's a known bug on which I will have a look (cf. https://github.com/lou/multi-select/issues/81)
Hi there,
I ran into the same issue and want to ask if it will be fixed soon? The Refresh method is a good solution but selected items should stay selected while the Select box gets disabled.
By the way: Very nice jquery extension...thank you very much for that.
Greets.
+1 for fixing this. There is no way to disable certain items based on another multiselect choices
+1 Again :)
Hello, I want insert my coin.
$('.ms-elem-selectable ').addClass('disabled');
$('.ms-elem-selection.ms-selected').addClass('disabled');
@BioQwer the soution worked for me...Thanks a ton