Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable jquery ui combobox?

Tags:

jquery-ui

I use standard code taken from this page and try to disable combobox:

$( "#cbCountry" ).combobox({ disabled: true });

But it is still enabled. What is wrong here?

like image 958
LA_ Avatar asked Oct 05 '11 19:10

LA_


People also ask

How to disable autocomplete in jQuery?

The jQuery UI Autocomplete disable() method is used to disable the autocomplete widget.


1 Answers

Easy modification to combobox library to use:

$("#cbCountry").combobox('disable');
$("#cbCountry").combobox('enable');

In your combobox.js file add:

  • in _create: function() add local variable "a" (after var input, a ...).
  • Change input = $("<input>") to input = this.input = $("<input>").
  • Change a = $("<a>") to a = this.a = $("<a>").
  • Insert after destroy:
    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");
    }
    
  • like image 195
    Domenico Avatar answered Nov 03 '22 05:11

    Domenico



    Donate For Us

    If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!