I''m trying to get a vanilla text_field_with_auto_complete and
observe_field to work together to no avail.
I have four sets of field and observer rendering on one page, and
each one should match the names of whatever ActiveRecord class
(passed as parent) they autocomple against. The observe field should
fetch the name of the item selected, and send it to another
controller action then update <ul id="#{parent}-actions> with the
results from that action.
But I can''t get the observe_field to trigger, not even if I code the
id of the text_field statically.
Here''s the code, what am I missing? Is there a better way to do this?
------------------------------------------------------------
# _form.rhtml
<p><label for="<%= parent %>_name">Find <%= h(
parent ) %></label>
<%= text_field_with_auto_complete :"#{parent}", :name, { :size
=> 30 } -%></p>
<% observe_field "#{parent}_name", :frequency => 1,
:url => { :controller => ''dashboard'',
:action =>
''regenerate_action_list'' },
:update => "#{parent}-actions",
:with => "''item='' + escape(value)",
:complete => visual_effect(:highlight, "#{parent}-
actions", :duration => 1 ) %>
# index.rhtml
...
render :partial => ''form'', :locals => { :parent =>
parent_1 }
render :partial => ''form'', :locals => { :parent =>
parent_2 }
render :partial => ''form'', :locals => { :parent =>
parent_3 }
render :partial => ''form'', :locals => { :parent =>
parent_4 }
...
------------------------------------------------------------
Thanks,
Kjell [http://station11.net]