Button_tag not working inside table in Rails

自古美人都是妖i 提交于 2020-01-16 11:58:32

问题


I have the following button_tag inside a form in a 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>

My index.js.erb (called every 10 seconds, renders the table above):

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

This button works perfectly outside the table (in the first div as commented in the code), but it does not work at all inside the table after an ajax call (partial reload).

I have several link_to's that work inside the table, even after the ajax call, but none of the button_tags for the forms work at all.


回答1:


Fixed this issue by switching all my button_tag's to link_to's by following this great guide:

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



来源:https://stackoverflow.com/questions/50325140/button-tag-not-working-inside-table-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!