我想在asp.net/mvc3多個表上使用jQuery tablesorter插件。我正在學習本教程: http://weblogs.asp.net/hajan/archive/2011/02/09/table-sorting-amp-pagination-with-jquery-in-asp-net-mvc.aspxjquery插件,tablesorter分頁器與多個表
我的頁面上有兩個不同的表格。我希望能夠使用此插件爲每個表設置行數。我所遇到的一個問題是默認情況下,表格有第一個表格顯示的行數。然後我可以在每張桌子上使用這個插件。因此,例如,下面的表1,我有這樣的:
<div id="pagerOwnerRequests">
<form>
<select id="selectOwnerRequests" class="pagesize">
@*<select id="selectOwnerRequests" class="pagesizeOwnerRequests">*@
<option selected="selected" value="0">0</option>
<option value="2">2</option>
<option value="10">10</option>
</select>
</form>
</div>
下表2,我有這樣的:
<div id="pagerBoardRequests">
<form>
<select id="selectBoardRequests" class="pagesize">
<option selected="selected" value="1">1</option>
<option value="2">2</option>
<option value="10">10</option>
</select>
</form>
</div>
在我這個頁面.cshtml文件的底部,我有這樣的:當頁面加載
$(document).ready(function() {
$("#tbOwnerRequests").tablesorter({
headers: {
6: {
sorter: false
}
}
}
).tablesorterPager({ container: $("#pagerOwnerRequests"), size: $(".pagesize option:selected").val() });
});
$(document).ready(function() {
$("#tbBoardRequests").tablesorter({
headers: {
7: {
sorter:false
}
}
}
).tablesorterPager({ container: $("#pagerBoardRequests"), size: $(".pagesize option:selected").val() });
});
會發生什麼,因爲表1中的下拉列表設置爲0,表1與表2有0個元素。那麼當我手動進入並更改表1或表2的下拉列表時,它會正確更新。我不知道爲什麼。我剛開始使用jQuery/html/css,所以很抱歉,如果答案很明顯,但我似乎無法看到它。 TIA。