我正在使用带有ajax的PagedList。一切正常。但唯一的问题是,当我点击它们时,页面链接没有得到更新。
这是包含列表的部分视图
@model IEnumerable<UniProject.Models.Short_Code>
<table class="table table-condensed table-bordered table-hover table-striped">
<tr>
<th>
Shortcode
</th>
<th>
Service
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ServiceCode)
</td>
<td>
@Html.DisplayFor(modelItem => item.Service)
</td>
</tr>
}
</table>
这是我的观点
@model PagedList.IPagedList<UniProject.Models.Short_Code>
@using PagedList.Mvc
<link type="text/css" rel="stylesheet" href="~/Content/PagedList.css" />
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<div class="col-lg-8">
<div id="tableDiv">
@Html.Partial("_shortcode_table" , Model)
</div>
<div id="myPager">
@Html.PagedListPager(
Model,
page => Url.Action(
"Index",
new
{
page = page
}
)
)
</div>
</div>
<script>
$(function () {
$('#myPager').on('click', 'a', function () {
$.ajax({
url: this.href,
type: 'GET',
cache: false,
success: function (result) {
$('#tableDiv').html(result);
}
});
return false;
});
});
</script>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
请帮助解决我在哪里做错的问题。任何帮助都会受到欢迎。感谢