如何使用tablesorter过滤搜索

时间:2014-07-08 04:45:32

标签: tablesorter

我正在使用tablesorter搜索/过滤器插件来搜索列表中的名称。所以当我输入与列表中的字母相对应的字母时,将显示。我使用了这个:http://mottie.github.io/tablesorter/docs/example-widget-filter-external-inputs.html作为参考。 以下是我的代码:

var $table = $('#table').tablesorter({
    sortList: [[0,0], [1,0]],
    theme: 'blue',
    widgets: ["zebra", "filter"],
    widgetOptions : {
        filter_columnFilters: false,
        filter_saveFilters : true,
    }
}); 
$.tablesorter.filter.bindSearch( $table, $('.search-subaccounts') );

HTML:

<input class="search-subaccounts" type="search" data-column="1"/>

我正在尝试根据名字过滤名称。 所以当我尝试执行它时,给我以下错误:

Uncaught TypeError: Cannot read property 'bindSearch' of undefined 

我不知道为什么它说“过滤器”是未定义的,而我试图完全按照它在演示中的方式执行。我在这做错了什么? 任何想法??

1 个答案:

答案 0 :(得分:0)

听起来好像未包含小部件文件,因为找不到bindSearch函数 - 它包含在过滤器小部件中。确保在页面上加载以下文件(主题文件名将根据您的选择而有所不同):

<link rel="stylesheet" href="css/theme.blue.css">
<script src="js/jquery.min.js"></script>
<script src="js/jquery.tablesorter.min.js"></script>
<script src="js/jquery.tablesorter.widgets.min.js"></script>