Button_tag在 Rails 的表格内不起作用



我在table的表单中有以下button_tag:

<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>

我的索引.js.erb(每 10 秒调用一次,呈现上表(:

$("#todaysarticles").html("<%= escape_javascript(render(:partial => 'todaysarticles')) %>")

此按钮在表外完美运行(在代码中注释的第一个div 中(,但在 ajax 调用(部分重新加载(后,它在表内根本不起作用。

即使在 ajax 调用之后,我也有几个在表内工作的link_to,但表单的button_tags根本不起作用。

按照这个很棒的指南将所有button_tag切换到link_to来解决此问题:

http://buckybits.blogspot.com/2011/09/simple-ajax-property-toggle-in-rails-30.html

最新更新