Originally I had my view setup like:
<%= render layout: 'form' do |f| %>
<% for holiday in Holiday.find(:all) %>
<label class="checkbox">
<%= check_box_tag "user[holiday_ids][]", holiday.id, @user.holidays.include?(holiday) %>
<%= holiday.name %>
</label>
Which rendered a list of 8 "interests". However, I needed 3 out of these 8 to have unique div id's in order to have a jquery show/hide function to display divs below them when checked. To do this i just took the html rendered by the above erb code and pasted it into my view and manually modified it to work with the jquery statement (pasted below).. My question is that in these div's that are displayed by the jquery i need to have a dropdown which is populated by another model in my app.. How can i achieve this? I attempted the statement in the first div but its causing the following error (code taken from my _form partial):
undefined method `map' for nil:NilClass
Extracted source (around line #12):
9: </ul>
10: </div>
11: <% end %>
12: <%= yield f %>
13:
14: <div class="actions">
15: <%= f.submit "Continue" %>
Here is the HTML + erb statement i am attempting..
<%= render layout: 'form' do |f| %>
<div id="checkbox">
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="2" />
Valentine Day
</label>
</div>
<div style="display:none;">
<%= select_tag 'Interests', options_for_select(@interests) %>
</div>
<div id="checkbox">
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="4" />
Mothers Day
</label>
</div>
<div style="display:none;">
Whatever you have to capture here<input type="text" id="foo2" />
</div>
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="7" />
Thanksgiving
</label>
<div id="checkbox">
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="5" />
Father's Day
</label></div>
<div style="display:none;">
Whatever you have to capture here<input type="text" id="foo3" />
</div>
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="3" />
Easter
</label>
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="6" />
Halloween
</label>
<label class="checkbox">
<input id="user_holiday_ids_" name="user[holiday_ids][]" type="checkbox" value="8" />
Christmas
</label>?
<% end %>
No comments:
Post a Comment