我有一个带有可排序表格的简单html页面。我使用TableSorter 2.17.8分钟
<html>
<head>
<link href="${pageContext.request.contextPath}/resources/css/base.css" rel="stylesheet"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/resources/js/rules.js"></script>
</head>
<body>
<table id="rulesTable" class="tablesorter">
<tr>
.....
我的rules.js有
$(document).ready(function() {
$("#rulesTable").tablesorter({
widthFixed : true,
showProcessing: true,
widgets: ['zebra', 'columns', 'stickyHeaders'],
debug: true,
theme: 'blue'
});
});
但是当我加载页面时,我一直收到此错误
ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized jquery.tablesorter.min.js:5d jquery.tablesorter.min.js:5g.setup jquery.tablesorter.min.js:5(anonymous function) jquery.tablesorter.min.js:5n.extend.each jquery-2.1.1.min.js:2n.fn.n.each jquery-2.1.1.min.js:2g.construct jquery.tablesorter.min.js:5(anonymous function) rules.js:4j jquery-2.1.1.min.js:2k.fireWith jquery-2.1.1.min.js:2n.extend.ready jquery-2.1.1.min.js:2I jquery-2.1.1.min.js:2
答案 0 :(得分:1)
根据您发布的内容,您似乎没有thead或tbody,这会导致插件出错,因为它需要这些标记。 应该是这样的:
<table id="rulesTable" class="tablesorter">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
如果这不起作用,请尝试将插件路径移动到更简单的位置,以确保它能够正常运行。