Tyler Kovacs
2005-Aug-24 11:06 UTC
[Rails-spinoffs] Re: triggering autocomplete with a button press
I''ve got a search field on my site that uses an autocomplete to match
against search terms already input by the same user. That''s working
perfectly. However, I''d like to provide a little button next to the
search field that triggers the autocomplete, so that the users can
"browse" the list of past search terms. This behavior would be in
addition to the standard autocomplete behavior in the search field.
I''ve tried the following without success:
<input autocomplete="off" id="search"
name="search" size="20"
type="text" value="" />
<div class="autocomplete"
id="recent_searches_autocomplete"></div>
<script type="text/javascript">search_ac = new
Ajax.Autocompleter(''search'',
''recent_searches_autocomplete'',
''/search/auto_complete_for_recent_searches'');</script>
<img src="/images/button.gif"
onClick="javascript:search_ac.show()">
When the user clicks on the button image, it invokes the autocomplete
show() function. This correctly displays the autocomplete drop-down
div, but it is not active - the items do not highlight when I hover
over them, nor can I scroll through the items using the arrows keys.
I''ve tried various combinations (setting min_chars to 0, setting
has_focus, changed and active to true, invoking addObservers(), etc.)
but none of them have the desired effect. Is there a way to trigger
the autocomplete field using an external function call?
Thanks,
Tyler
Thomas Fuchs
2005-Aug-24 11:22 UTC
[Rails-spinoffs] Re: triggering autocomplete with a button press
Currently, no. A patch to controls.js to allow for this shouldn''t be very difficult, any volunteers? :) Thomas Am 24.08.2005 um 18:25 schrieb Tyler Kovacs:> Is there a way to trigger the autocomplete field using an external > function call?