johnpolacek / stacktable.js

jQuery plugin for stacking tables on small screens
http://johnpolacek.github.io/stacktable.js/
Other
1.03k stars 167 forks source link

Rebind cardtable? #51

Open alkanegit opened 7 years ago

alkanegit commented 7 years ago

Hi.

Is there a way to rebind cardtable?

On initial load I bind like so: $('#searchresults').cardtable();

And on subsequent paging, I call the same again: $('#searchresults').cardtable();

But the cardtable doesn't update the 'hidden' table? Any advice please?

alkanegit commented 7 years ago

Fixed it:

//if ($table.hasClass('stacktable')) { // return; //} //remove paged temp stackable $(".pagedStackable").remove();

and i rebind after each page like so: $('#searchresults').cardtable({ myClass: 'pagedStackable' });

alkanegit commented 7 years ago

Added another 'fix' too. If I have a blank row in my table (intentionally) I do not want the header key in my stacked table. So I put a class on the <tr> like so <tr class="blankkey">:

Then after
$table.find('>tbody>tr').each(function() { I add var trclassname = $(this).attr('class');

and i change this line: if ($topRow.find('>td,>th').eq(cellIndex).html()){ to this if ($topRow.find('>td,>th').eq(cellIndex).html() && trclassname != "blankkey"){

seems to work....