:after_update_element on text_field_with_auto_complete


#1

I have a a basic prototype coded:

#view
<%= text_field_with_auto_complete :student, :last_name, { :size => 15
},
:after_update_element => “alert(‘hello world’);” %>

#controller
class ScoresController < ApplicationController
auto_complete_for :student, :last_name
end

If I take out the :after_update_element option everything works as
advertised. However, with :after_update_element specified nothing
works. The ajax call to the server does not happen.

I am running Rails 1.1.2 on Mac 10.4.6 with Ruby 1.8.4. I am testing
this with Safari.

Does anyone know why this doesn’t work?


#2

Jason
> <%= text_field_with_auto_complete :student, :last_name, { :size
=> 15 },
> :after_update_element => “alert(‘hello world’);” %>

This is the wrong syntax: a function is expected.
Try instead:
:after_update_element => “function(element,value){alert('You have
chosen: '+value)}”

Alan


#3

oops, typo:

> Alan

should read :
Alain.

:slight_smile: