Skip to main content

Search and Top Navigation

#5619 closed bug (fixed)

Opened May 17, 2010 07:24AM UTC

Closed July 30, 2010 05:00PM UTC

Last modified November 19, 2010 06:26PM UTC

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:
Blocked by: Blocking:
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.

Attachments (0)
Change History (7)

Changed May 17, 2010 07:42AM UTC by ggp comment:1

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 );

}

}

Changed May 17, 2010 08:13AM UTC by ggp comment:2

an easier fix:

$('#my_input').autocomplete({

search: function(event, ui) {

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

return false;

}

}

});

Changed July 30, 2010 10:39AM UTC by jzaefferer comment:3

milestone: TBD1.9
priority: majorcritical
version: 1.8.11.8.2

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

Changed July 30, 2010 10:40AM UTC by jzaefferer comment:4

component: ui.coreui.autocomplete

Changed July 30, 2010 05:00PM UTC by scottgonzalez comment:5

resolution: → fixed
status: newclosed

Fixed in 90caa93.

Changed August 04, 2010 01:18AM UTC by scottgonzalez comment:6

milestone: 1.91.8.3

Changed November 19, 2010 06:26PM UTC by Scott González comment:7

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

Changeset: 90caa93a9b4b9b894b055cfb8dae0661ac7788b0