【发布时间】:2012-07-12 03:19:56
【问题描述】:
在 jQuery 插件 jPaginate 中,子对象的数量始终返回由此代码确定的值 1(jPaginate.js 中的第 45-48 行):
//getting the amount of elements inside parent element
var number_of_items = obj.children().size();
//calculate the number of pages we are going to have
var number_of_pages = Math.ceil(number_of_items/show_per_page);
我在 document.ready 函数的 header 中调用脚本:
$("#content").jPaginate({
items: 4,
pagination_class: "pagination",
minimize: true
});
然后我将一个 id="content" 的 div 包裹在我想要这样分页的表格行周围:
<div id="content">
<table class="stripeMe center box-shadow-inner">
<?php foreach ($invoices as $invoice) { ?>
<tr>
<td>
<a href='<?php echo $_SERVER['PHP_SELF']; ?>/retrieve?class=InvoiceLineItems&id=<?php echo $invoice['invoice_id']; ?>'><?php echo $invoice['invoice_number']; ?></a> <?php echo $invoice['customer_name'] ?> <?php echo $invoice['invoice_date'] ?>
</td>
</tr>
<?php } ?>
</table>
</div>
我得到的是一长页记录,分页选择器设置为“上一个”1“下一个”。我尽可能地检查、删除和替换代码并调试了三倍。我仍然无法确定为什么 number_of_items 被设置为 1。
感谢任何帮助。 谢谢。
【问题讨论】:
标签: jquery jquery-plugins