Button_tag在Rails的表内不起作用 [英] Button_tag not working inside table in Rails

查看:148
本文介绍了Button_tag在Rails的表内不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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>

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

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

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

此按钮在表外部(在代码中注释的第一个div中)完美工作,但是在ajax调用(部分重载)后,在表内部完全不起作用.

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

即使在ajax调用之后,我也有几个link_to可以在表中使用,但是这些表单的button_tags都不起作用.

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.

推荐答案

通过遵循以下出色指南,将我所有的button_tag切换为link_to,解决了此问题:

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

这篇关于Button_tag在Rails的表内不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆