【发布时间】:2014-06-24 14:44:08
【问题描述】:
我正在使用 html.erb 在 rails 应用程序中生成视图。
我正在使用 "each do | |" 生成组合框
如何使用 jquery 遍历动态生成的组合框的值,并在组合框的任何值相同时提醒用户。
<table class="holiday_allowance_schedule tabular_data_cell">
<thead>
<th class="years_from_accrual_start">
<%= a(:company_policy, :years_from_accrual_start) %>
</th>
<th class="months_allocated"><%= a(:company_policy, :days_allocated) %></th>
<th></th>
<th></th>
</thead>
<tbody id="schedule_table">
<% @policies.holiday_allocation_schedule.keys.sort.each do |year| -%>
<tr id="<%= year %>">
<% days = @policies.holiday_allocation_schedule[year] %>
<td><%= select_tag("holiday_schedule[][year]", options_for_select(holiday_allocation_years_options, year)) %></td> #combo boxes with years
<td><%= select_tag("holiday_schedule[][days]", options_for_select(holiday_allocation_days_options, days)) %></td>
<td class="actions"><%= add_icon %></td>
<td class="actions"><%= remove_icon %></td>
</tr>
<% end -%>
</tbody>
</table>
例如:有五个组合框
1 年
2 年
3 年
4 年
5 年
如果用户在任意两个或更多组合框中选择“3 年”,则必须显示警报
如何使用 jquery 或使用 erb 本身来完成此操作
【问题讨论】:
标签: jquery ruby-on-rails erb