Hi, If i add field observers to radio button fields they trigger once but then nothing after that. I have multiple fields in a form that i need to know if one of them changes and which spedific field. Below is an example of two foelds i tested and they trigger once with the alert but then nothing after that. I also tried individual observers for each field test_yes and test_no but with the same issue. <%= radio_button_tag ''test'', "yes" %> <%= radio_button_tag ''test'', "no" %> <%= observe_field(''test'', :on => ''click'', :function => "alert(''Element Yes changed'')"%> Does anyone know why or experienced something like this before? JB -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If I remember correctly, I think you''ll need an id on each radio button and need to observe each radio button individually. The ''grouping'' of the radio buttons into a single field value that''s posted back does not replace the fact that it''s actually a collection of individual html elements on the form. On May 16, 4:07 pm, John Butler <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > If i add field observers to radio button fields they trigger once but > then nothing after that. I have multiple fields in a form that i need > to know if one of them changes and which spedific field. Below is an > example of two foelds i tested and they trigger once with the alert but > then nothing after that. I also tried individual observers for each > field test_yes and test_no but with the same issue. > > <%= radio_button_tag ''test'', "yes" %> > <%= radio_button_tag ''test'', "no" %> > > <%= observe_field(''test'', > :on => ''click'', > :function => "alert(''Element Yes changed'')"%> > > Does anyone know why or experienced something like this before? > > JB > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AndyV wrote:> If I remember correctly, I think you''ll need an id on each radio > button and need to observe each radio button individually. The > ''grouping'' of the radio buttons into a single field value that''s > posted back does not replace the fact that it''s actually a collection > of individual html elements on the form. > > On May 16, 4:07 pm, John Butler <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Ye ive tried adding an observer to each individual radio button but the same thing happens. <%= observe_field(''test_yes'', :on => ''click'', :function => "alert(''Element Yes changed'')"%> <%= observe_field(''test_no'', :on => ''click'', :function => "alert(''Element Yes changed'')"%> Im just going to have to post the whole form back and find out which one is set to 1 and do it that way. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You might want to try observe_form, http://wiki.rubyonrails.org/rails/pages/observe_form+-+Passing+Parameters -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- Radio Button Tag and hash @Params.
- observe_field and radio button... does not work?
- Interesting radio button behavior with "onclick"
- How to Pass Jquery selected dropdown values and radio button values to controller
- radio_button_tag - examining the selected value