Home > OS >  Pagination Link Not Clickable with JQuery
Pagination Link Not Clickable with JQuery

Time:04-14

I have the following code on the Razor page and the JS function is supposed to be called when the link is clicked, but nothing happened. It seems disabled. Could anyone help with this? Below is the code:

Code on Razor page:

                @for(var pge = Model.StartPage; pge <= Model.EndPage; pge  )
                {
                        <li active" : "")">
                            <a id="@("#plink"   pge)" 
                               data-action="@ViewData["ActionName"]"
                               data-pg="@pge"
                               data-pageSize="@ViewData["PageSize"]"
                               data-category="@ViewData["CategoryId"]"
                               data-categoryAction="@ViewData["CategoryAction"]"
                               data-currentSearchFilter="@TempData["CurrentSearchFilter"]">
                                @pge
                            </a>
                        </li>
                }

JQuery:

                $(function () {
                    $(".rpt_btn_lnk").click(function () {
                        var pageSize = $(this).attr('data-pageSize');
                        var pg = $(this).attr('data-pg');
                        var category = $(this).attr('data-category');
                        var categoryAction = $(this).attr('data-categoryAction');
                        var currentSearchFilter = $(this).attr('data-currentSearchFilter');
                        var action = $(this).attr('data-action');
                        $("#partialRptList").load("/Report/"   action   "?id="   id   "&pg="   pg   "&category="   category   "&categoryAction="   categoryAction
                              "&currentSearchFilter="   currentSearchFilter   "&pageSize="   pageSize);
                    });
                });

CodePudding user response:

Don't know if the pagination is DOM loaded?

Try replacing $(".rpt_btn_lnk").click(function () { with $(document).on('click', '.rpt_btn_lnk', function(){

  • Related