【发布时间】:2015-01-06 21:36:13
【问题描述】:
有人知道如何在不破坏 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);
}
})
})
【问题讨论】:
标签: jquery tablesorter