ravid7000 / table-sortable

A jquery plugin to sort and paginate data in table form.
https://table-sortable.now.sh
MIT License
35 stars 14 forks source link

Error: tableSortable.element "[object Object]" is not a valid root element #10

Closed Hidieh closed 3 years ago

Hidieh commented 4 years ago

Getting error "Uncaught TableSortable Violation: tableSortable.element "[object Object]" is not a valid root element" and no table is rendered.

My current code:

var columns = {
  ID: 'ID',
  Nimi: 'Nimi',
  Rotu: 'Rotu',
  Painotus: 'Painotus',
  Sukupuoli: 'Sukupuoli',
  Talli: 'Talli',
  Pisteet: 'Pisteet',
  Arvosana: 'Arvosana',
}

var options = {
  data: data,
  columns: columns,
  rowsPerPage: 15,
  pagination: true,
  sorting: true,
}

var table = $('#table-sortable').tableSortable(options);

table-sortable.js and newest jQuery are correctly in the and the script is just before And div with "table-sortable" class is on the page I want the table to render.

My data can be seen from here (sorry, not stylish but it's rendered via php from mysqli and I think it should work even though it looks ugly?): https://pastebin.com/GNyJ9N9T

I must me missing something cause can't figure out what object is in the root?! My site is a Wordpress site if that helps, can't link since it's still in local development though.

arobert3434 commented 4 years ago

I'm not a javascript expert but maybe try quoting the field names in your data and dropping trailing commas?

ravid7000 commented 3 years ago

Please make sure div has Id instead of class. Because var table = $('#table-sortable').tableSortable(options); this is taking element by id. If you want to use class then change the selector to .table-sortable like var table = $('.table-sortable').tableSortable(options);