【发布时间】:2011-10-11 09:25:40
【问题描述】:
我正在使用 jQuery TableSorter 插件并使用此代码收到以下错误 Uncaught TypeError: Cannot set property 'count' of undefined:
$(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;
});
});
HTML 是:
<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 -->
我复制表头的原因是我需要拆分表头才能使我的应用程序结构正常工作。 这部分很好但是因为类等被添加到原始标题中,我需要再次使用新标题更新 HTML 这很好。但我得到错误?任何想法为什么或如何解决它?谢谢
【问题讨论】:
标签: jquery tablesorter