button custom attributes - typescript

button custom attributes - typescript

spownerspowner Posts: 2Questions: 2Answers: 0

Hello, I'm a beginner in typescript, so sorry if this is a stupid question.

I have a problem with button creation. I need to add custom attributes to button, but it doesn't work... documetation

IDE tells me that it doesn't recognize attr in the config. When I look in types.d.ts in ButtomSettingsCommon attr type is missing. Without typescript it works fine. What am I doing wrong? Is there any way to add an attribute?

 const table = $('#sourcesTable').DataTable({
        lengthMenu: [10, 20, 50, 75, 100],
        order: [[0, 'desc']],
        pageLength: 20,
        language: langCz,
        select: {
            style: 'single'
        },
        rowId: 'staffId',
        dom: 'Bfrtip',
        buttons: [
            {
                text: '<i class="bi bi-trash3-fill"></i> Delete',
                className: 'btn btn-danger ajax',
                attr: {
                    'data-bs-toggle': 'modal',
                    'data-bs-target': '#sourceModal'
                },
            }
        ]
    });

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Not a daft question at all. It looks like I missed the attr option in the Typescript definitions file! Sorry about that. I've committed it now and you could paste in the latest types file to your local copy as a little workaround until I release the Buttons update (which will probably be next week).

    Allan

Sign In or Register to comment.