I''m trying to use the results of an auto complete form in a field
observer. The problem is the value of the field is just a select item
in a UL. So if I have this:
<%= text_field_with_auto_complete :school, :name %>
<%= observe_field ''school_name'',
:url => {:action => ''get_students_by_school''},
:update => ''student_list'',
:with => ''school[name]'' %>
I type ''an'', select ''Anderson High'' or
whatever and the parameters
look like this:
"school"=>{"name"=>"an"}
My latest hack attempt was to have the observer render a
link_to_remote button (''find school'') with the value of
li.selected as
its id. Couldn''t get that to work.
When you submit the form, obviously the value of the school[name]
parameter is correct, so I''d like to know how I can recreate this
functionality in my field observer.
As an aside, I can''t find the documentation on the auto complete
helper in the API.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Xavier Noria
2007-Dec-13 00:52 UTC
Re: Value of text_with_auto_complete_field for field observer
On Dec 12, 2007, at 10:33 PM, Aaron wrote:> I''m trying to use the results of an auto complete form in a field > observer. The problem is the value of the field is just a select item > in a UL. So if I have this: > > <%= text_field_with_auto_complete :school, :name %> > > <%= observe_field ''school_name'', > :url => {:action => ''get_students_by_school''}, > :update => ''student_list'', > :with => ''school[name]'' %>I guess onchange is not fired because the field is in the end set with JavaScript. You''ll surely need to pass some JavaScript for the :after_update_element hook of the rightmost optional parameter completion_options. That JavaScript would do what you wanted to do with the observe_field, which would be removed. -- fxn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2007-Dec-13 00:59 UTC
Re: Value of text_with_auto_complete_field for field observer
On Dec 13, 2007, at 1:52 AM, Xavier Noria wrote:> On Dec 12, 2007, at 10:33 PM, Aaron wrote: > >> I''m trying to use the results of an auto complete form in a field >> observer. The problem is the value of the field is just a select >> item >> in a UL. So if I have this: >> >> <%= text_field_with_auto_complete :school, :name %> >> >> <%= observe_field ''school_name'', >> :url => {:action => ''get_students_by_school''}, >> :update => ''student_list'', >> :with => ''school[name]'' %> > > I guess onchange is not fired because the field is in the end set > with JavaScript. You''ll surely need to pass some JavaScript for > the :after_update_element hook of the rightmost optional parameter > completion_options. That JavaScript would do what you wanted to do > with the observe_field, which would be removed.Let me add that with model_auto_completer[*] you could send back the school ID instad of the name via its own :after_update_element hook. Depending on the data that would be a better way to get the list of students of the school. -- fxn [*] http://agilewebdevelopment.com/plugins/model_auto_completer --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Awesome. I''ll try this out and let you know how it goes. On Dec 12, 6:59 pm, Xavier Noria <f...-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> On Dec 13, 2007, at 1:52 AM, Xavier Noria wrote: > > > > > On Dec 12, 2007, at 10:33 PM, Aaron wrote: > > >> I''m trying to use the results of an auto complete form in a field > >> observer. The problem is the value of the field is just a select > >> item > >> in a UL. So if I have this: > > >> <%= text_field_with_auto_complete :school, :name %> > > >> <%= observe_field ''school_name'', > >> :url => {:action => ''get_students_by_school''}, > >> :update => ''student_list'', > >> :with => ''school[name]'' %> > > > I guess onchange is not fired because the field is in the end set > > with JavaScript. You''ll surely need to pass some JavaScript for > > the :after_update_element hook of the rightmost optional parameter > > completion_options. That JavaScript would do what you wanted to do > > with the observe_field, which would be removed. > > Let me add that with model_auto_completer[*] you could send back the > school ID instad of the name via its own :after_update_element hook. > > Depending on the data that would be a better way to get the list of > students of the school. > > -- fxn > > [*]http://agilewebdevelopment.com/plugins/model_auto_completer--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---