0
任何人都知道如何卸载过滤器小部件而不破坏tablesorter并在没有过滤器小部件的情况下重新启用它?从Tablesorter卸载过滤器小部件
这是我使用的代码,它非常糟糕,笨重。
<a href="#" data-active="1" class="togglefilter btn btn-primary">Toggle Filter</a>
$(function(){
$(".togglefilter").click(function(){
var active = $(this).data('active');
if(active == 1)
{
$("table").trigger('destroy');
$("table").tablesorter({
theme : "bootstrap",
widthFixed : true,
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
widgets : ["uitheme","zebra"],
widgetOptions : {
zebra : ["even", "odd"],
filter_reset : ".reset"
}
});
$(this).data('active', 0);
}
else
{
$("table").trigger('destroy');
$("table").tablesorter({
theme : "bootstrap",
widthFixed : true,
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
widgets : ["uitheme", "filter", "zebra"],
widgetOptions : {
zebra : ["even", "odd"],
filter_reset : ".reset"
}
});
$(this).data('active', 1);
}
})
})