Struggling with Javascript and esbuild (Rails 7)

There are two pages für data-*-attributes:

Since I don’t much variation between tables, I try to put as much into the controller to make the html page simple. And indeed I’m using data-order, i.e.

<%= content_tag :table, id: 'users_table',
      class: "table table-bordered table_striped",
      data: {
        url: users_url(format: :json),
        order: [[0, 'asc']].to_json 
      } do %>

Sadly these pages are not exhaustive, I was hoping to find something like https://datatables.net/reference/option/columnDefs (for example).

I found this on Options :

There are two important points to consider when using data-* attributes as initialisation options:

  • jQuery will automatically convert from dashed strings to the camel case notation used by DataTables (e.g. use data-page-length for pageLength).
  • If using a string inside the attribute it must be in double quotes (and therefore the attribute as a whole in single quotes). This is another requirement of jQuery’s due to the processing of JSON data.

It seems you can use all options like order or pageLength, but to be sure you can ask on the datables forum.

I have a working example of rails 7, esbuild, datatables and bootstrap, if you are interested:

https://github.com/nkokkos/datatables_rails_7