auto_complete_for: prevent the first item from being auto-selected
Asked Answered
M

4

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?

Madid answered 26/3, 2011 at 20:35 Comment(1)
Can you give the url of the plugin that you use?Ptolemy
P
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.

Picked answered 12/4, 2011 at 19:16 Comment(0)
P
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

Ptolemy answered 12/4, 2011 at 2:5 Comment(0)
C
0

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

Chorale answered 12/4, 2011 at 8:53 Comment(0)
A
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.

Aggarwal answered 13/4, 2011 at 17:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.