neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-29 18:52 UTC
observer with group of radio buttons
Hi, My code looks like this <%get_date_ranges().each{|arr|%> <input type="radio" id="criteria[<%=count%>][date_range]" name="criteria[<%=count%>][date_range]" value="<%=arr[0]%>" /> <%=arr[1]%> </br> <%}%> <%= observe_field("criteria[#{count}][date_range]", :url => { :action => :date_range, :count => count,:type_id => type_id, :report_key => report_key }, :frequency => 3, :with => "''type_id=''+value") %> I have a group of radio buttons and i want the observer to fire an action when any radio button is checked. But the observer is not working. Can someone suggest what could be the possible reason for it not to work. Neha --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 2/29/08, neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > My code looks like this > <%get_date_ranges().each{|arr|%> > <input type="radio" id="criteria[<%=count%>][date_range]" > name="criteria[<%=count%>][date_range]" value="<%=arr[0]%>" /> > <%=arr[1]%> > </br> > <%}%> > > <%= observe_field("criteria[#{count}][date_range]", > :url => { :action => :date_range, :count => > count,:type_id => type_id, :report_key => report_key }, > :frequency => 3, > :with => "''type_id=''+value") %> > I have a group of radio buttons and i want the observer to fire an > action when any radio button is checked. > But the observer is not working. Can someone suggest what could be the > possible reason for it not to work.Well you seem to have a loop which generates multiple buttons all apparently with the same id (which should be unique), then you set up one observer after the loop. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-29 21:09 UTC
Re: observer with group of radio buttons
But if i have a group of radio buttons, they should have the same id so that they form a group Also if i give them different ids then on what will my observer field act? On Feb 29, 2:45 pm, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 2/29/08, neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi, > > > My code looks like this > > <%get_date_ranges().each{|arr|%> > > <input type="radio" id="criteria[<%=count%>][date_range]" > > name="criteria[<%=count%>][date_range]" value="<%=arr[0]%>" /> > > <%=arr[1]%> > > </br> > > <%}%> > > > <%= observe_field("criteria[#{count}][date_range]", > > :url => { :action => :date_range, :count => > > count,:type_id => type_id, :report_key => report_key }, > > :frequency => 3, > > :with => "''type_id=''+value") %> > > I have a group of radio buttons and i want the observer to fire an > > action when any radio button is checked. > > But the observer is not working. Can someone suggest what could be the > > possible reason for it not to work. > > Well you seem to have a loop which generates multiple buttons all > apparently with the same id (which should be unique), then you set up > one observer after the loop. > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
On 2/29/08, neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > But if i have a group of radio buttons, they should have the same id > so that they form a group > Also if i give them different ids then on what will my observer field > act?No it''s the name which groups the buttons: http://www.echoecho.com/htmlforms10.htm Dom ids should be unique, or it''s quite likely that the browser will get confused at best. I think that you either need an observer for each button, or if they are in a form you can use observe_form which will trigger when any element in the form changes. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
neharohan.chopra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-29 22:32 UTC
Re: observer with group of radio buttons
If i give them all different ids, then will it be possible to have a observe_field on the name of the radio buttons as the number of buttons is quite high and i dont want to have a separate observer for each button as that will make the code quite cumbersome. And my form is being built up dynamically so i cant have observe_form also. On Feb 29, 5:12 pm, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 2/29/08, neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <neharohan.cho...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > But if i have a group of radio buttons, they should have the same id > > so that they form a group > > Also if i give them different ids then on what will my observer field > > act? > > No it''s the name which groups the buttons:http://www.echoecho.com/htmlforms10.htm > > Dom ids should be unique, or it''s quite likely that the browser will > get confused at best. > > I think that you either need an observer for each button, or if they > are in a form you can use observe_form which will trigger when any > element in the form changes. > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---