On Mon, May 30, 2011 at 6:27 PM, Jason Fleetwood-Boldt <t...@datatravels.com > wrote:
> > On May 30, 2011, at 6:27 PM, David Kahn wrote: > > <div class="ui-field-contain ui-body ui-br" data-role="fieldcontain"> > <fieldset class="ui-corner-all ui-controlgroup ui-controlgroup-vertical" > data-role="controlgroup"> > <div class="ui-checkbox"> > <input id="foo_bar_ids_" type="checkbox" value="19" name=" > link[bar_ids][]" checked="checked"> > </div> > <label for="19">Jquery</label> > <div class="ui-checkbox"> > <input id="foo_bar_ids_" type="checkbox" value="25" name=" > foo[bar_ids][]" checked="checked"> > </div> > <label for="25">Web</label> > </fieldset> > </div> > > > > David, > > I think I see your problem. The for attribute of the label tag has to match > the id attribute of the input checkbox. You have two input checkboxes with > ids of "foo_bar_ids_" -- that's not really allowed by HTML, you should > make that be "foo_bar_ids_19" and "foo_bar_ids_25" > > The for of the label tag should match the id of the input tag -- this is > actually how HTML works and has nothing to do with rails (see > http://www.w3schools.com/tags/tag_label.asp). I always thought that was > counter intuitive myself but that's how it works. > > To do that, you specify *:id =>* in the check_box_tag and also* :for > =>*label_tag (you happen to not be using label_tag, but if you were you could > specify :id => ) > > Personally I never use HABTM, because I always find I'm going to eventually > want to add a field to the join table which you can't do with HABTM. Use > has_many :through => instead of HABTM. (but that is actually irrelevant to > the problme you have) > Thats a good point... I just got killed by using HABTM and ended up creating a join model. Especially if you are dealing with nested forms and want to create the join record specifically based on data in the form. > > -Jason > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.