filamentgroup / tablesaw

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

How to refresh hidden table in swipe mode? #243

Closed cschults closed 8 years ago

cschults commented 8 years ago

I believe I'm experiencing a similar issue as noted in #163, but unclear on the proper way to refresh a table.

On my page I have several tables, hidden on page load. The user can then toggle these tables, but often only one column is visible until the window is resized (desktop) or one scrolls on a phone.

Now I have an unconventional implementation as the site is using an antiquated version of jQuery. Thus I'm not using the jQuery version of Tablesaw. However, I would like to trigger a Tablesaw refresh within jQuery code.

cschults commented 8 years ago

FYI: In my jQuery code I'm identifying the ID of the table in question (for example: tablesaw-5652) and passing to the following function where I've confirmed that $ is an alias for 'shoestring':

function table_refresh(id) { $("#" + id).data('table').refresh(); }

However, I'm getting the following error: Uncaught TypeError: Cannot read property 'refresh' of undefined

cschults commented 8 years ago

For the error noted in my previous comment, I resolved this by using 'tablesaw' instead of 'table'. This caused the number of visible columns to be fixed, but unfortunately limited it to only one non-persistent column when viewing on my phone where I knew additional columns could fit.

What seems to be working for me, after re-reading the documentation, is to not include tablesaw-init.js and use trigger("enhance.tablesaw") when showing a hidden table instead of refresh().