Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Llamar a la función de JavaScript desde PagedListPager no funciona

Tengo una Html PagedList como la siguiente,

 <div id="contentPager"> @Html.PagedListPager(Model, page => Url.Action("ServerPaging", new { page })) </div>

Y este es el HTML de salida para buscapersonas,

 <div id="contentPager"> <div class="pagination-container"> <ul class="pagination"> <li class="active"> <a>1</a> </li> <li> <a data-ajax="true" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-update="#targetContainer" href="/MyController/ServerPaging?page=2">2</a> </li> <li> <a data-ajax="true" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-update="#targetContainer" href="/MyController/ServerPaging?page=3">3</a> </li> </ul> </div> </div>

Quiero que se llame a la función Javascript del evento de clic cuando haga clic en los números de página de este buscapersonas sin ir a la acción del servidor ServerPaging . Así es como he implementado el detector de eventos de Javascript.

 $(document).on("click", "#contentPager a", function () { //............ });

Pero sigue llamando a la acción del servidor ServerPaging .

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Elimine la URL de la propiedad href y establezca la función de anulación.

 <a data-ajax="true" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-update="#targetContainer" href="javascript:void(0)" data-pageno="2" >2</a>

Luego, debe obtener el número de página del atributo data-pageno en la función de evento:

 $(document).on("click", "#contentPager a", function () { var pNo = this.data("pageno"); alert(pNo); });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!