Autocomplete and save onblur

Hi all,

I have am autocomplete field that (is supposed) to save the selection as
soon as it selected from the drop down. The issue is that the method to
save is called before the selection is made because when I click the
selection is when the onblur happens. Here is my code:

" style = "padding-right: 16px; <% if @contract.all_airports == true %>display: none;<% end %>">
<% @toregion = Region.find_by_id(@contract.to_region) %>
<% func_contract_to_region = remote_function( :complete =>
‘Element.hide(’’);’, :loading =>
‘Element.show(‘loading_contract_to_region_div_’
+ @contract.id.to_s +
‘’);’, :url => {
:action => ‘save_contract_attribute_auto_complete’,
:model => ‘contract’, :attr => ‘to_region’,
:contract_id => @contract.id, :look_up_model => ‘Region’,
:look_up_attr => ‘region_name’,
:field_id => ‘to_region_’ + @contract.id.to_s},
:submit => ‘contract_to_region_div_’ + @contract.id.to_s) -%>

To Region

<%= text_field_with_auto_complete_with_id_checking
:region, :region_name, {:id => ‘to_region_’ + @contract.id.to_s,
:value => !@toregion.blank? ? @toregion.region_name : ‘’,
:size => 20, :onblur => func_contract_to_region},
{:url => {
:action => “auto_complete_for_region_region_name”,
:pseudo_id => @pseudo.id }
} %>

I can’t think of another way to make this happen, such as through a
onclick, onkeydown, etc. I think if I used onfocus this method would get
called twice, when I first click in the field to enter the data, and a
second time when I make the selection, and I think it would make this
work
awkwardly.

Just wondering if anybody has tried this and got it to work the way they
wanted? Thanks,

-S