<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Blah Blah Woof Woof comments on observe_field and radio buttons</title>
    <link>http://vault.openmonkey.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Blah Blah Woof Woof comments</description>
    <item>
      <title>"observe_field and radio buttons" by triley</title>
      <description>&lt;p&gt;Without specifying any extra options for Ruby on Rails&amp;#8217; &lt;code&gt;radio_button&lt;/code&gt; or &lt;code&gt;radio_button_tag&lt;/code&gt; form tag helpers, each tag will share the same &lt;code&gt;id&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt; attributes.&lt;/p&gt;


	&lt;p&gt;While the &lt;code&gt;name&lt;/code&gt; attribute needs to be shared for a set of radio buttons to work properly, sharing the &lt;code&gt;id&lt;/code&gt; attribute is not necessary and will also break the &lt;code&gt;observe_field&lt;/code&gt; JavaScript helper.  In this case, the field observer will only be triggered for any events in the first of the radio buttons with the specified &lt;code&gt;id&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;Fortunately, you can set the &lt;code&gt;id&lt;/code&gt; manually:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
 &amp;lt;%= radio_button_tag "button_name",
   "button_val",
   checked,
   :id =&amp;gt; "my_custom_id" %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Then, using a separate observer for each radio button in your set with a unique &lt;code&gt;id&lt;/code&gt;, you can effectively observe any change in the set.  Watch out, radio buttons!&lt;/p&gt;

</description>
      <pubDate>Mon, 13 Mar 2006 21:20:00 PST</pubDate>
      <guid>&lt;a href="/articles/2006/03/13/observe_field-and-radio-buttons"&gt;observe_field and radio buttons&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2006/03/13/observe_field-and-radio-buttons"&gt;observe_field and radio buttons&lt;/a&gt;</link>
    </item>
  </channel>
</rss>

