multi-select icon indicating copy to clipboard operation
multi-select copied to clipboard

Disable Element via JavaScript

Open campino-rocks opened this issue 11 years ago • 9 comments

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

campino-rocks avatar Apr 24 '13 14:04 campino-rocks

I can see two ways to do this:

  1. Disable all options in the menu $('.ms-elem-selectable').addClass('disabled')
  2. Recreate it. $('#includedUsers').attr('disabled', true); on the element with multiSelect 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.

ridiculous avatar Apr 25 '13 00:04 ridiculous

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.

lou avatar Jul 02 '13 20:07 lou

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

campino-rocks avatar Jul 22 '13 09:07 campino-rocks

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)

lou avatar Jul 22 '13 09:07 lou

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.

WulleBulle avatar Nov 04 '13 14:11 WulleBulle

+1 for fixing this. There is no way to disable certain items based on another multiselect choices

fri3ndly avatar Mar 15 '15 21:03 fri3ndly

+1 Again :)

ezk84 avatar Aug 03 '15 09:08 ezk84

Hello, I want insert my coin.

$('.ms-elem-selectable ').addClass('disabled');
$('.ms-elem-selection.ms-selected').addClass('disabled');

image

BioQwer avatar May 31 '16 14:05 BioQwer

@BioQwer the soution worked for me...Thanks a ton

hmnshuagarwal avatar Jan 18 '17 06:01 hmnshuagarwal