Auto_complete_for: disable automatic selection of the first element

The auto_complete_for dealio function from script.aculo.us is great for everyone, but is there any way I can selectively disable the fact that it always automatically selects the first item in the list?

The problem is that if I want to print my own record, which is new and new, I do not want the first item in the list to be automatically selected. The reason is that when I TAB from the field, it selects and fills the text field with this first element.

I got around this a bit by making the first item on the list the same as what I am typing, but that is not ideal either, because the auto_complete list is not always updated with every keystroke, depending on how fast I type. I tried to set the refresh rate of the list to the lowest value (1 millisecond), but did not leave.

What I really want is an option in "auto_complete_for" that does not select this first element at all - just like Google Instant does not automatically select the first suggested search phrase - you need a down arrow to select one.

Maybe I can do this through an HTML option that I am missing?

+8
ajax ruby-on-rails scriptaculous
source share
4 answers

Looking at the source, there is no option for this, but I'm sure if you changed the line of 284 controls. js before this.index = -1; he will do what you want.

Otherwise, it may take time to search for another autocomplete widget.

+2
source share

If your requirements are too far from the available plugin, I think there is no point in messing around. It is 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

0
source share

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

0
source share

I recently implemented automatic completion for more than fields for Rails 2.0.2.

Used plugin: - https://github.com/david-kerins/auto_complete . Not sure if Rails 3 supports.

I also ran into problems when implementing the above script and posted questions ( Implementing auto-completion for multiple fields in Rails ; Implementing OnClick function and formatting for Rails Partial-Views ) for stackoverflow for the same, I was lucky that I work for me based on my requirement.

Please refer to these questions, they may be relevant to your requirements.

0
source share

All Articles