Reputation: 11202
I have this simple html page with a sortable table. I'm using TableSorter 2.17.8 min
<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>
.....
My rules.js has
$(document).ready(function() {
$("#rulesTable").tablesorter({
widthFixed : true,
showProcessing: true,
widgets: ['zebra', 'columns', 'stickyHeaders'],
debug: true,
theme: 'blue'
});
});
But i keep getting this error when i load the page
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
Upvotes: 0
Views: 453
Reputation: 11
From what you posted it doesn't appear that you have a thead or tbody, and that would cause the plugin to error because it needs those tags. Should look like:
<table id="rulesTable" class="tablesorter">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
If that doesn't work try moving the plugin path to a more simple location just to make sure it is able to reach it fine.
Upvotes: 1