Rails 5.2数据表将不会刷新页面更改中的数据

时间:2019-04-30 17:57:08

标签: ruby-on-rails datatables ruby-on-rails-5

我有一个配置了数据表的Rails 5.2项目。该插件可以正常工作,但是如果我更改页面,然后单击“后退”按钮,则表中的数据不会再与datatables一起加载。它说“表中没有数据”。这听起来像是我的turbolinks问题。

我正在使用以下内容来生成表:

Zoo

datatables插件在页面更改之间加载,但表中的数据不会刷新。有关如何解决此问题的任何想法?

更新:Application.js

$( document ).on('turbolinks:load', function() {
  $("#prjtbl").dataTable();
});

Page.js

        // This is a manifest file that'll be compiled into application.js, which will include all the files
    // listed below.
    //
    // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
    // vendor/assets/javascripts directory can be referenced here using a relative path.
    //
    // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
    // compiled file. JavaScript code in this file should be added after the last require_* statement.
    //
    // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
    // about supported directives.
    //
    //= require rails-ujs
    //= require jquery
    //= require datatables
    //= require popper
    //= require bootstrap-sprockets
    //= require shards-dashboards
    //= require trix
    //= require activestorage
    //= require turbolinks
    //= require_tree .

1 个答案:

答案 0 :(得分:0)

-f file