I am writing an ASP.NET MVC application. I have a grid using PagedListPager like this:
<div style="float:left;width:70%;margin-left:10%" id="contentPager">
@Html.PagedListPager((IPagedList)Model.SearchResultViewPaging, page => Url.Action("SearchPaging", "Participant", new { page = page, pageSize = ViewBag.PageSize, order = ViewBag.CurrentSort }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new PagedListRenderOptions
{
DisplayLinkToIndividualPages = true,
DisplayPageCountAndCurrentLocation = false,
LiElementClasses = new string[] { "page-item" },
PageClasses = new string[] { "page-link" },
},
new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "dvBody",
}))
</div>
It works fine...
What I need is to add a Javascript validation before calling the Url Method. Depend on the result of the validation, the Url has to be executed or not.
What I did is adding
$(document).on("click", "#contentPager a", function (event) {
alert(1);
});
This function is called when I click the paging... But I do not know if it possible to prevent the calling to the Url method... it is always executed
I have tried using
$(document).on("click", "#contentPager a", function (event) {
event.stopPropagation();
event.preventDefault();
return false;
});
Without any result..
It is possible to prevent it?
Thanks