Ticket #5619 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

Autocomplete widget keeps looking for remote data even when it's disabled

Reported by: ggp Owned by:
Priority: critical Milestone: 1.8.3
Component: ui.autocomplete Version: 1.8.2
Keywords: autocomplete disable disabled remote Cc:
Blocking: Blocked by:

Description

I think that autocomplete widget shouldn't send Ajax request to server looking for data when the option 'disabled' is true. I don't know if that's a bug or it's thought to work that way, but I think this isn't correct because server receives load even when you're not interested in its response.

If the source of autocomplete is a remote database with a lot of rows to fetch, this is critical. I want to search data only when clicking a 'search' button, and now it's impossible.

Change History

comment:1 Changed 4 years ago by ggp

I propose to replace the current _search method with this:

if (this.options.disabled == false) {

always save the actual value, not the one passed as an argument this.term = this.element.addClass( "ui-autocomplete-loading" ).val();

this.source( { term: value }, this.response );

}

To use it as a fix in current production environments I propose to use this code:

$.ui.autocomplete.prototype._search = function(value) {

if (this.options.disabled == false) {

always save the actual value, not the one passed as an argument this.term = this.element.addClass( "ui-autocomplete-loading" ).val();

this.source( { term: value }, this.response );

}

}

comment:2 Changed 4 years ago by ggp

an easier fix:

$('#my_input').autocomplete({

search: function(event, ui) {

if($(this).autocomplete('option', 'disabled') == true) {

return false;

}

}

});

comment:3 Changed 4 years ago by joern.zaefferer

  • Priority changed from major to critical
  • Version changed from 1.8.1 to 1.8.2
  • Milestone changed from TBD to 1.9

The suggested solution is probably too specific. Autocomplete doesn't care for the disabled option at all, that needs to be fixed.

comment:4 Changed 4 years ago by joern.zaefferer

  • Component changed from ui.core to ui.autocomplete

comment:5 Changed 4 years ago by scott.gonzalez

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in  90caa93.

comment:6 Changed 4 years ago by scott.gonzalez

  • Milestone changed from 1.9 to 1.8.3

comment:7 Changed 4 years ago by Scott González

Autocomplete: Respect the disabled option. Fixes #5619 - Autocomplete widget keeps looking for remote data even when it's disabled.

Changeset: 90caa93a9b4b9b894b055cfb8dae0661ac7788b0

Note: See TracTickets for help on using tickets.