8

The auto_complete_for dealio from script.aculo.us is great an all, but is there a way for me to selectively disable the fact that it always auto-selects the first item in the list?

The problem is that, if I want to type my own entry that is new, and novel, I don't want the first item in the list to be auto-selected. The reason is because when I TAB out of the field, it selects, and fills the text box with that first item.

I got around that, somewhat, by making the first item in the list the same as what I'm typing, but that's not perfect either, because the auto_complete list doesn't always update with every keystroke, depending on how fast I type. I've tried setting the list refresh rate to the lowest value (1 millisecond) but no go.

What I really want is an option in "auto_complete_for" that doesn't select that first item at all - the same way that Google Instant doesn't automatically select the first suggested search phrase - you have to arrow-down to select one.

Maybe I can do this via an HTML option that I'm missing?

jefflunt
  • 33,527
  • 7
  • 88
  • 126

4 Answers4

2

Looking at the source, there doesn't appear to be an option for that, but I bet if you changed line 284 of controls.js to this.index = -1; it would do what you want.

Otherwise, it might be time to look for a different autocomplete widget.

Austin Taylor
  • 5,437
  • 1
  • 23
  • 29
0

If your requirements are too far away from the available plugin, then I guess there is no point in tinkering around. Its best to write your own JS code.

You might want to consider this: https://github.com/laktek/jQuery-Smart-Auto-Complete

or this : https://github.com/reinh/jquery-autocomplete

Anand
  • 10,310
  • 24
  • 90
  • 135
0

I'll add another alternative that works great with Rails 3: http://github.com/crowdint/rails3-jquery-autocomplete

Markus Proske
  • 3,356
  • 3
  • 24
  • 32
0

I recently implemented auto complete for more than a field for Rails 2.0.2.

The plugin I used is:- https://github.com/david-kerins/auto_complete . Not sure if it supports Rails 3.

I have also encountered issues on implementing the above scenario and have posted questions( Implementing auto complete for more than one field in Rails ; Implementing a OnClick kind of functionality and formatting wrt Rails Partial-Views ) on stackoverflow for the same, I have been lucky on getting things working for me based on my requirement.

Kindly refer to these questions, they might have relevance to your requirement.

Community
  • 1
  • 1
boddhisattva
  • 6,908
  • 11
  • 48
  • 72