Reputation: 149
I hope this is not a duplicate question. I have searched enough on Stackoverflow to find an answer my simplest question.
I have a set of radiobox and based on the values of the radiobox I need to disable / enable the user from selecting a from combobox.
Whatever I do, I am not able to make the combobox ReadOnly or Disabled. I use the JQueryUI by directly linking it to http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js. The code to make the normal combobox to the jQuery is as follows:-
$('#cbCountry").combobox();
I tried different methods specified in different places on the net. Nothing seems to work.
Upvotes: 1
Views: 6425
Reputation: 2707
Boulliou's answer is the better one. Here is another way:
If you do use $.autocomplete
then:
$('#cbCountry").autocomplete( "option", "disabled", true );
Upvotes: 0
Reputation: 208
Easy modification to combobox library to use:
$("#cbCountry").combobox('disable');
$("#cbCountry").combobox('enable');
In your combobox.js file add:
input = $("<input>")
to input = this.input = $("<input>")
.a = $("<a>")
to a = this.a = $("<a>")
.--
disable: function() {
this.input.prop('disabled',true);
this.input.autocomplete("disable");
this.a.button("disable");
},
enable: function() {
this.input.prop('disabled',false);
this.input.autocomplete("enable");
this.a.button("enable");
}
Upvotes: 3
Reputation: 14025
I have just checked, and you right, disable a combobox is more complex than we could think.
So, I made a fiddle for you that you can find here : http://jsfiddle.net/S77xa/61/
Upvotes: 0