I'm using the jQuery TableSorter plugin and get the following error Uncaught TypeError: Cannot set property 'count' of undefined
with this code:
$(document).ready(function () {
var copyThead = $(".uiGridContent thead").html();
copyThead = '<table><thead>' + copyThead + '</thead></table>';
$(".uiGridHeader").html(copyThead);
$(".uiGridContent table").tablesorter();
$(".uiGridContent table thead").hide();
$(".uiGridHeader th").click(function () {
// Get updated HTML
var FindcopyThead = $(".uiGridContent thead").html();
var NewcopyThead = '<table><thead>' + FindcopyThead + '</thead></table>';
$(".uiGridHeader").html(NewcopyThead);
var index = $(".uiGridHeader th").index(this);
var sorting = [[index, 0]];
$(".uiGridContent table").trigger("sorton", [sorting]);
return false;
});
});
and the HTML is:
<div class="uiGrid">
<div class="uiGridHeader">
<!-- NEW HEADER GOES HERE -->
</div>
<div class="uiGridContent">
<table class="list sortable">
<thead>
<tr>
<th scope="col"><input type="checkbox" id="checkall" /></th>
<th scope="col">Name</th>
<th scope="col">Post Code</th>
<th scope="col">SIC Code</th>
<th scope="col">№ of Employees</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<!-- ROWS -->
The reason I copy the Table Header is because I need to have the header split off for the structure of my app to work. This part is fine BUT because the classes etc get added to the original headers I need to keep updating the HTML with the new ones again this works fine. But I get the error? Any ideas why or how to fix it? Thanks