我正在尝试让 jQuery 表格排序器的寻呼机工作。没有寻呼机一切正常,但是当我尝试使用寻呼机时出现问题。
当我不将寻呼机的限制从 10 更改为 5 或 2 时,排序和分页都不起作用。然后它向我展示了一张空桌子。但是,当我事先更改限制时,一切正常?!这不是应该的,对吧?^^
jQuery:
<script>
$(document).ready(function(){
var validator = $("#searchForm").validate({
});
});
$(document).ready(function()
{
$("#myTable")
.tablesorter({widthFixed: true, widgets: ['zebra']})
.tablesorterPager({container: $("#pager")});
});
桌子:
// name of database dable == header of table
echo "<table id=\"myTable\" class=\"tablesorter\"><thead><tr>";
foreach( sqlsrv_field_metadata($stmt) as $fieldMetadata)
{
echo "<th>".$fieldMetadata ['Name']."</th>";
}
echo "<th>Details</th>";
echo "</thead>";
echo "<tbody>";
// printing table rows
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell){
echo "<td>$cell</td>";
}
echo "</tr>\n";
}
echo "</tbody>";
echo "</table>";
echo("<br>");
寻呼机:
<div id="pager" class="pager">
<form>
<img src="/images/first.png" class="first"/>
<img src="/images/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="/images/next.png" class="next"/>
<img src="/images/last.png" class="last"/>
<select class="pagesize">
<option value="">>LIMIT</option>
<option value="2">2 per page</option>
<option value="5">5 per page</option>
<option value="10">10 per page</option>
</select>
</form>
</div>