0
我有迴路,其中我請的部分爲循環的每次迭代:現在如何傳遞變量從一個模態for循環
<% applications.each do |application| %>
<td>
<%= render :partial => "layouts/form", :locals => {:@application => application} %>
</td>
<% end %>
,內部分,我有按下時按鈕將顯示一個模式:
<button type="button" class="button-custom btn-primary" data-toggle="modal" data-target="#form-modal"> <%= "#{button_text}" %> </button>
<div id="form-modal" class="modal fade modal-form" role="dialog" tabindex='-1'>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<td> <%= "#{@application.name}" %> </td>
現在的問題是,總是@application.name
指的是第一應用的內for循環的值。它沒有得到對應於循環的相應迭代的值。
這沒有辦法。 – user1175969
答案已更新。你應該生成一個獨特的模式ID。 –
太棒了!這就是賽道。謝謝! – user1175969