Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

278
Visualizações
Calling JavaScript function from PagedListPager doesn't work

I have a Html PagedList like below,

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

And this is the output HTML for pager,

<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> 

I want the click event Javascript function to be called when I click page numbers from this pager without going to server action ServerPaging. This is how I have implemented the Javascript event listener.

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

But it's still calling the server action ServerPaging.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Remove the Url from the href property and set to void function.

    <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>

Then you need to get the page number from the data-pageno attribute in the event function:

$(document).on("click", "#contentPager a", function () {
    var pNo = this.data("pageno");
    alert(pNo);
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda