我试图使用jquery.tablesorter.pager.js为我的表控件添加分页。jQuery Tablesorter分页按钮不会触发
JavaScript文件
/*global my */
my.Views.EndingSoon = (function ($) {
"use strict";
var pagerOptions = {
container: $("#pager"),
output: '{startRow:input} – {endRow}/{totalRows} rows',
updateArrows: true,
page: 0,
size: 10,
savePages: true,
storageKey: 'tablesorter-pager',
pageReset: 0,
fixedHeight: true,
removeRows: false,
countChildRows: false,
cssNext: '.next', // next page arrow
cssPrev: '.prev', // previous page arrow
cssFirst: '.first', // go to first page arrow
cssLast: '.last', // go to last page arrow
cssGoto: '.gotoPage', // select dropdown to allow choosing a page
cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
cssDisabled: 'disabled', // Note there is no period "." in front of this class name
cssErrorRow: 'tablesorter-errorRow' // ajax error information row
};
var init = function init() {
$("table")
.tablesorter({
theme: 'blue',
widthFixed: true,
widgets: ['zebra', 'filter']
})
.tablesorterPager(pagerOptions);
}
return {
init: init
};
})(this.jQuery);
视图(CSHTML)文件
<table class="tablesorter">
<thead>
<tr>
<th>Auction Source</th>
<th>Short Description</th>
<th style="width: 100px">Current Price</th>
<th style="width: 125px">Next Required<br />Bid Amount</th>
<th>Number of Bids</th>
<th>Auction End</th>
</tr>
</thead>
<tbody>
@foreach (AuctionItem item in Model.AuctionItems)
{
<tr>
<td>@item.Auction.AuctionSource</td>
<td><a target="_blank" href="@item.AuctionItemURL" title="@item.FullDescription">@Truncate(string.IsNullOrEmpty(item.ShortDescription) ? item.FullDescription : item.ShortDescription, 100)</a></td>
<td>@item.CurrentPrice.ToString("C")</td>
<td>@item.NextBidRequired.ToString("C")</td>
<td>@item.NumberOfBids</td>
<td>@(item.EndDateTime != DateTime.MinValue ? item.EndDateTime : item.Auction.AuctionEndDate)</td>
</tr>
}
</tbody>
</table>
<div id="pager" class="pager tablesorter-pager">
<img src="@Url.Content("~/Content/Images/first.png")" class="first" />
<img src="@Url.Content("~/Content/Images/prev.png")" class="prev" />
<!-- the "pagedisplay" can be any element, including an input -->
<span class="pagedisplay" data-pager-output-filtered="{startRow:input} – {endRow}/{filteredRows} of {totalRows} total rows"></span>
<img src="@Url.Content("~/Content/Images/next.png")" class="next" />
<img src="@Url.Content("~/Content/Images/last.png")" class="last" />
<select class="pagesize">
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="all">All Rows</option>
</select>
<select class="gotoPage" title="Select page number">
</select>
</div>
捆绑代码
bundles.Add(new ScriptBundle("~/bundles/jquerytablesorter").Include(
"~/Scripts/jquery.tablesorter.js",
"~/Scripts/jquery.tablesorter.combined.js",
"~/Scripts/jquery.tablesorter.pager.js"));
共享_Layout.cshtml片段
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jquerytablesorter")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/my-js")
@Scripts.Render("~/bundles/bootstrap")
</head>
<body>
个
脚本文件夹
分页似乎是“努力”的工作,因为只有前10行显示。但是,分页控件不会触发任何事件。
如果这会有帮助,我可以推动我的网站的github页面。
这就是我试图效仿:https://mottie.github.io/tablesorter/docs/example-pager.html
我不是很熟悉,但我没有在你有mottie链接快速“F12开发工具”的样子。我注意到他们的例子中,他们没有像你一样的
是否在jQuery&tablesorter之后加载了'jquery.tablesorter.pager.js'文件? – Mottie
刚刚尝试删除表单标签,没有运气那里。我可以看到,当我调试时,pager.js文件在jQuery和tablesorter之后列出。我还包括我的捆绑逻辑进行审查。感谢你目前的帮助。 – NickHeidke