Hi there !
François Beausoleil said the following on 2005-09-20
16:58:> My current thought is to forget about auto_complete_result and build my
> own partial. In there, I could make the LI''s ID the
supplier''s, and
> finally, I would need some way to know when the selection was made, to
> update a hidden field.
>
> Does that sound like a good plan ? Or is there something already
> built-in ?
Well, I went ahead and implemented it. I had to upgrade to the
scriptaculous HEAD because the necessary afterUpdateElement callback did
not exist prior to that.
Also, since the Rails helper for autocomplete doesn''t know about the
afterUpdateElement callback, I had to do it manually. Things look like
this:
<%= hidden_field :product, :supplier_id %>
<%= text_field :supplier, :name, :size => 40 %>
<div class="auto_complete"
id="supplier_name_auto_complete"/>
<script type="text/javascript">
new Ajax.Autocompleter(''supplier_name'',
''supplier_name_auto_complete'',
''/admin/product_catalog/products/auto_complete_for_supplier_name'',
{afterUpdateElement: function(element, selectedElement) {
$(''product_supplier_id'').value
selectedElement.id.substring(1);}});</script>
I haven''t made myself any helpers yet, but I''ll probably end
up needing
one real soon now...
Bye !
François