【问题标题】:Button_tag not working inside table in RailsButton_tag 在 Rails 中的表内不起作用
【发布时间】:2018-05-14 07:33:32
【问题描述】:

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

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

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

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

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

【问题讨论】:

    标签: html bootstrap-4 ruby-on-rails-5 twitter-bootstrap-rails


    【解决方案1】:

    按照这个出色的指南将我所有的 button_tag 切换为 link_to 解决了这个问题:

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

    【讨论】:

      猜你喜欢
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-19
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多