Forum: Ruby on Rails auto_complete_field, :on_hide woes

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
E74a19a983b0da1c671de90b341e7c06?d=identicon&s=25 James Hughes (Guest)
on 2006-03-10 02:13
(Received via mailing list)
I have auto_complete working generating a list and populating a text
box in a form. The problem arises when I add the :on_hide option as

<%= auto_complete_field "search",
{ :url => {:action => "search"}, :on_hide => "foo($('selected_uid'),
$('search_list'))"} > %>

:on_hide makes everything stop working ('search' action doesn't get
called); in addition, the div that is supposed to contain the
selection list becomes visible beneath the text box as an ugly grey

Also, the javascript in the on_hide parameter gets executed on page
load; why is that?

Here's the generated html for the form:

<form action="/users/show" method="post">
  Search by surname:
    <input autocomplete="off" id="search" name="search" type="text" />
    <div id="search_auto_complete"></div>
	 <input type="hidden" name="selected_uid" id="selected_uid"/>

  	 <script type="text/javascript">
new Ajax.Autocompleter('search', 'search_auto_complete',
'/users/search', {onHide:foo($('selected_uid'), $('search_list'))})
	 <input name="commit" type="submit" value="Show" />

Anyone have some working auto_complete_field code that uses :on_hide
(or :on_show) that they could share?

James Hughes
Web application developer
Centre for Health Services and Policy Research
Vancouver, BC

"Developing a coherent political analysis is in many respects
contingent upon an ability to connect one context to another, a
process not dissimilar to playing the kid's game of dot-to-dot."
 - Ward Churchill, from '"A Government of Laws"?'
This topic is locked and can not be replied to.