Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove jQuery tablesorter from table

I am using the jQuery tablesorter (http://tablesorter.com).

After being applied to a table by $('#myTable').tablesorter(), how can I remove it again from the table?

like image 596
psx Avatar asked Nov 17 '11 17:11

psx


3 Answers

There isn't a built-in function to do this, but you could remove the class names and event bindings to stop its functioning... try something like this:

$('table')
 .unbind('appendCache applyWidgetId applyWidgets sorton update updateCell')
 .removeClass('tablesorter')
 .find('thead th')
 .unbind('click mousedown')
 .removeClass('header headerSortDown headerSortUp');

The above won't work if you have the pager plugin running.

like image 56
Mottie Avatar answered Nov 14 '22 14:11

Mottie


tablesorter2.0

$("#table").trigger("destroy");

or if you just in need to update all after appending new thead :

$("#table").trigger("updateAll");

-> http://mottie.github.io/tablesorter/docs/index.html

like image 19
Volker Ahlers Avatar answered Nov 14 '22 15:11

Volker Ahlers


Latest version of table sorter library provides Destroy method

From version 2.16 destroy() method has been added in table sorter library, use this method to remove tablesorter from the table.

like image 6
Sanjeev Avatar answered Nov 14 '22 15:11

Sanjeev