我在table
:
<div class="table-responsive tableBG">
** If I move the button here, it works perfectly **
<table class="table table-striped table-sm table-mini">
<thead class="thead">
<tr>
<th>...</th>
</tr>
</thead>
<tbody>
<tr>...</tr>
...
<%= form_for article, :html => {:class => 'toggle'} do |f| %>
<%= f.hidden_field :disable, value: true %>
<%= button_tag type: 'submit', class: "btn-mini" do %>
<i class="fa fa-eye-slash" aria-hidden="true"></i>
<% end %>
<% end %>
...
</tbody>
</table>
</div>
我的index.js.erb(每10秒调用一次,呈现上面的表格):
$("#todaysarticles").html("<%= escape_javascript(render(:partial => 'todaysarticles')) %>")
这个按钮在表格之外完美地工作(在代码中注释的第一个div中),但是在ajax调用(部分重新加载)之后,它在表内部根本不起作用。
我有几个link_to在表中工作,即使在ajax调用之后,但是表单的button_tags都没有工作。
答案 0 :(得分:0)
通过按照以下精彩指南将所有button_tag
切换为link_to
来解决此问题:
http://buckybits.blogspot.com/2011/09/simple-ajax-property-toggle-in-rails-30.html