1
私は次のコードを使用して、一連の製品に対してブランド/モデル/サブモデル/スタイルのリストを生成しています。破棄ボタンがクリックされたときにテーブルから行全体を削除したいのですが、dom_idとjqueryの.remove()を使用して行う方法を理解できません。jquery .remove()を使用してテーブル行を削除するにはdom_idを使用してください。
これまでのところ、 $('#<%= dom_id(@brand) %>').remove();
成功しません。ありがとう!
<div class = "span8">
<table class="table table-striped" id="devices">
<thead>
<tr>
<th>Brand</th>
<th>Model</th>
<th>Submodel</th>
<th>Style</th>
<th></th>
</tr>
</thead>
<tbody>
<% @brands.each do |brand| %>
<tr>
<td><%= link_to brand.name, brand_path(brand) %></td>
<% @model1 = Model.find_by_brand_id(brand.id) %>
<td><%= @model1.name %></td>
<% @submodel1 = Submodel.find_by_model_id(@model1.id) %>
<td><%= @submodel1.name %></td>
<% @style1 = Style.find_by_submodel_id(@submodel1.id) %>
<td><%= @style1.name %></td>
<td style = "border:none;">
<%= link_to 'Edit', edit_brand_path(brand), :class => 'btn btn-mini' %>
<%= link_to 'Destroy', brand_path(brand), :method => :delete, :remote=>true, :confirm => 'Are you sure?', :class => 'btn btn-mini btn-danger' %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
これは、オンラインチュートリアルで作業して、すべての概念を完全に理解することなく、ニーズに合ったときに起こることです。私はそれがこのようなものになると思った。 – Abram
また、[record_tag_helper](https://github.com/rails/record_tag_helper)と呼ばれる宝石があります。あなたのループコードを '<%= content_tag_for(:tr、@brands)do | brand | %> 'を実行し、適切なIDとクラスで'
私は破棄ボタンを前提とは、あなたが次の操作を行うことができTRの内部にある、
出典
2012-04-04 20:49:20
ありがとう、私はこれも試してみます。最も簡単な解決策です。 – Abram
これは私にとっては何もしなかったことを恐れています。 – Abram
関連する問題