ビューに一意でないIDのテーブルがあります。列の1つにAjax対応の送信ボタンがあり、Ajaxの結果でIDに一致するテーブル内のすべての行を更新したいと思います。とにかくそれをすることはありますか?IDの最初の出現を更新するためにそれを取得することしかできませんでした。
助けてくれてありがとう!
関連するコードは次のとおりです。
私の見解ではテーブルコード。
<% @gifts.each do |gift| %>
<tr id="<%= gift.parent_id %>">
<% if gift.key_indicator == "Individual" %>
<td><%= gift.first_name %> <%= gift.last_name %></td>
<% else %>
<td><%= gift.organization_name %></td>
<% end %>
<td><%= l gift.gift_date.to_date, :format => :default %></td>
<td><%= number_to_currency(gift.fund_split_amount) %></td>
<td><%= if gift.fund_id =~ /\A[Xx]/ then :CND else :US end%></td>
<td><%= gift.preferred_primary_email_number %></td>
<td><% if @subscriber_ids.include?(gift.constituent_id) %>
Yes
<% else %>
<%= form_for(@teacher.mailing_list_edits.build(:parent_id => gift.parent_id),remote: true) do |f| %>
<div><%= f.hidden_field :parent_id %></div>
<%= f.submit "Add", :class => "btn btn-large btn-primary" %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
これが私のcreate.js.erbです
$('#<%= params[:mailing_list_edit][:parent_id] %>').html("foobar")