Sally
Sally

Reputation: 87

can't make msdropdown disabled

I'm new at jquery . I'm using msDropDown plugin which a plugin that makes a dropdown lsit with image and description and I'm facing a problem with making a msdropdown list disabled and then remove this attribute !! I've tried :

 $('#id').attr('disabled',true);

and

 $('#id').attr('disabled','disabled');

and

 $('#id').attr('disabledAll','disabledAll');

and

$('#id').addClass('disabled');

and

$('#id').addClass('disabledAll');

and

$('#id').disableSelection();

I'm out of solutions ! can any one helps me :(

Upvotes: 1

Views: 2536

Answers (1)

Barney
Barney

Reputation: 16456

The code you're using would work on a normal dropdown (<select>) element, but the plugin works in such a way that it creates new markup to emulate dropdown behaviour — it no longer supports native form element properties, so setting the disabled attribute has no effect on it.

However, the plugin does expose its own disabled property — it just isn't triggered the same way. The documentation could be clearer, but it says that you can use the .set() method to modify properties. Taking that into account, the code should be:

$('#id').data('dd').set('disabled', true);

…or, if it hasn't been initialized yet:

$('#id').msDropDown({disabled:true});

Upvotes: 5

Related Questions