Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #5435 (new enhancement)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Autocompleter should allow displaying options in empty field

Reported by: ssinghi@kreeti.com Assigned to: thomas@fesch.at
Priority: normal Milestone:
Component: script.aculo.us Version:
Severity: normal Keywords: autocompleter empty field
Cc:

Description

Hello,

I want the autocompleter to show the options immediately when the field gets focus. Right now at least one character must be typed for autocomplete to kick in.

   Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));
    Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));
Event.observe(this.element, "focus", this.onKeyPress.bindAsEventListener(this));

The last line is what I have added.

And then I have commented some code:

  onObserverEvent: function() {
    this.changed = false;   
    //    if(this.getToken().length>=this.options.minChars) {
      this.startIndicator();
      this.getUpdatedChoices();
//     } else {
//       this.active = false;
//       this.hide();
//     }
  },

The problem with these changes is that in an empty field it is not possible to select an item from the drop down by clicking on it. (using arrows and tabs work fine).

Please consider adding such a feature to autocompleter.

Change History

08/03/06 08:03:35 changed by max@waypoint.be

Hello,

I have exactly the same request. Can you explain to me what i have to do?

Thanks you.

MAx

03/04/07 19:50:48 changed by einfallsreich

  • summary changed from Autocompleter should allow displaying options in empty field to [PATCH] Autocompleter should allow displaying options in empty field.

I attached a patch that

  • adds a boolean activateOnFocus option to Autocompleter.Base
  • allows the minChars option to be 0
  • modifies the Autocompleter.Local default selector to return the whole array if the current token is empty.

Example: http://einfallsreich.net/projekte/thenewstuff/scriptaculus/test.html

Patch: http://einfallsreich.net/projekte/thenewstuff/scriptaculus/AutocompleterPatch.diff