Jason Hale
2006-Apr-16 15:53 UTC
[Rails] :after_update_element on text_field_with_auto_complete
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?
--
Posted via http://www.ruby-forum.com/.
Alain Ravet
2006-Apr-16 17:51 UTC
[Rails] Re: :after_update_element on text_field_with_auto_complete
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