filamentgroup / tablesaw

A group of plugins for responsive tables.
MIT License
5.48k stars 434 forks source link

Can't init a single table manually #340

Closed smknstd closed 5 years ago

smknstd commented 6 years ago

Here is my html

<table id="myTable" class="xnt-table-fr" data-tablesaw-mode="swipe">
   <thead>
   ...
   </thead>
</table>

I manage to init tablsaw globally

import Tablesaw from 'tablesaw';
...
console.log( "this should be the tablesaw object: ", Tablesaw ); //works great
Tablesaw.init(); //works great

But can't init a specific table...

Tablesaw.init("#myTable");

What's wrong ? Is there an example somewhere ?

Thanx

dszewczyk1 commented 6 years ago

You should not pass the table itself into init(), but rather a container in which there's a table with tablesaw attributes.

<table id="myTable" class="xnt-table-fr" data-tablesaw-mode="swipe">
</table>
</div>

And then

Tablesaw.init(document.querySelector("#myTableContainer"));

Also in my case (maybe because I was doing dynamic import) I had to call _init method instead.

Anastasia93 commented 5 years ago

@dszewczyk1 tnx a lot, it resolves my problem.

zachleat commented 5 years ago

This will work transparently in upcoming version v3.1.0