Forum: Ruby on Rails piggybacking an action on an autocompleted field

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.
Alain R. (Guest)
on 2006-04-02 01:51
Hi everybody,

I'd like to add a custom action to be triggered after/when an
autocompleted  field has been/is beeing updated by the autocompletion
I tried the obvious - a field observer -, but it doesn't work (see code
below). I know I could write the autocompletion code myself, but I
wonder if there is a simpler/more elegant way?

Any idea?


The observer solution (that doesn't work):

    <%= text_field_with_auto_complete :city, :zip    %>
    <%= observe_field("city_zip",
       :frequency => 0,
       :url => { :action => :get_names_for_zip },  <<<---- IS NEVER
       :with => "'zip='+value") %>
Alain R. (Guest)
on 2006-04-02 14:22
(Received via mailing list)
There's already a tiny patch - 3691 - in the waiting list that solves
that very problem, and lets you write
      <%= text_field_with_auto_complete :city, :zip ,{},
	        :after_update_element=> "alert('after_update_element...')"

    [PATCH] Add frequency and afterupdateelement option to

It justs adds 2 lines in the _auto_complete_field_ method
         js_options[:frequency]  = "#{options[:frequency]}" if
         js_options[:afterUpdateElement] = "function(element,value) {
return #{options[:after_update_element]}(element,value); }"  if
This topic is locked and can not be replied to.