Is there a way to control the url format of the pagination buttons?

Is there a way to control the url format of the pagination buttons?

RyanJRBRyanJRB Posts: 2Questions: 1Answers: 1

Hello,

It looks like the href attribute of the pagination buttons is "#". Is there a way to control that or remove the href entirely, since it isn't a link? The reason is that the href="#" is causing the subpage to link to the root, like "/#" instead of "/subpage#

If I remove the href through the dev tools, pagination works properly.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @RyanJRB ,

    I'm not following, I'm afraid, but you can create your own pagination controls - see here for a few existing ones. That will enable you to format those buttons as you please.

    Cheers,

    Colin

  • RyanJRBRyanJRB Posts: 2Questions: 1Answers: 1
    edited July 2019 Answer ✓

    Colin,

    I have since determined that this is a flaw in Blazor Preview 6, which misinterprets href="#" to act like href="/#". So your confusion about why that would happen is well-founded!

    Thanks for the example of creating the control from scratch. I might still do that for style purposes. But for now, I found a simple fix to be adding:

    $(".dataTables_wrapper a[href='#']").removeAttr("href");

    to the drawCallback option.

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin

    Odd bug that one - thanks for posting back.

    Allan

  • rdunawayrdunaway Posts: 6Questions: 1Answers: 0

    Removing the attribute works for the first click. Once I select page 2 the href=# is back.

    I'm running: $(".dataTables_wrapper a[href='#']").removeAttr("href");
    when I create the datatable. Is there somewhere else I should be running it?

  • rdunawayrdunaway Posts: 6Questions: 1Answers: 0

    Sorry. I see your drawcallback comment now. I didn't know what that was.

    This works great now. Thanks.

    function apply_General_DataTable(tableName) {

    $(document).ready(function () {
        $(tableName).DataTable({
            "pagingType": "full_numbers"
            , "drawCallback": function (settings) {
                $(".dataTables_wrapper a[href='#']").removeAttr("href");
            }
        });
    
    });
    

    }

This discussion has been closed.