I am using bootstrap tables on several pages of my app (on Rails 6) and the tables load correctly.
However, I want to enable the column sorting and search feature and these only appear when I refresh the page: with fixed-table-toolbar displayed
Some of my application.js:
require("@rails/ujs").start();
require("turbolinks").start();
require("@rails/activestorage").start();
require("channels");
require("jquery");
require("bootstrap");
require("chartkick");
require("chart.js");
import 'mapbox-gl/dist/mapbox-gl.css';
import "@fortawesome/fontawesome-free/js/all.js";
import 'bootstrap-table/dist/bootstrap-table.min.js';
import 'bootstrap-table/dist/locale/bootstrap-table-fr-FR.js';
Which is loaded in application.html.erb with <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
(I also tried to put the bootstrap-tables import in another pack file and import it separately.)
If I try to import bootstrap-table in a script at the bottom of my application.html.erb to see I will get these error messages, most likely because Jquery hasn't been loaded yet:
Uncaught TypeError: Cannot set property 'BootstrapTable' of undefined
Uncaught TypeError: Cannot set property 'BootstrapTable' of undefined
at VM1101 bootstrap-table.min.js:10
at VM1101 bootstrap-table.min.js:10
at VM1101 bootstrap-table.min.js:10
(anonymous) @ bootstrap-table.min.js:10
(anonymous) @ bootstrap-table.min.js:10
(anonymous) @ bootstrap-table.min.js:10
bootstrap-table-fr-FR.js:678
Uncaught TypeError: Cannot read property 'fn' of undefined
at VM1103 bootstrap-table-fr-FR.js:678
at VM1103 bootstrap-table-fr-FR.js:4
I am running out of ideas, after having moved my import files and script all around so I would be eternally grateful if someone already had the same issue and could share his/her thoughts! Thanks