≡

Issue with API button.node after v3 Upgrade

Issue with API button.node after v3 Upgrade

WernfriedWernfried Posts: 56Questions: 12Answers: 0

After upgrade I faced this issue with buttons API.

In version 2 I used, for example dt.buttons().each(button => { console.log(button.node.id) })

In version 3 I have to use dt.buttons().each(button => { console.log(button.node.get(0).id) })

whereas dt.buttons().each(button => { console.log(button.node().id) })
returns a Error "TypeError: button.node is not a function"

Maybe .each() is the wrong function to iterate over a list of buttons.

It's not a mayor issue, because I found a working solution. The question is rather: does it work as designed?

Best Regards
Wernfried

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 66,144Questions: 1Answers: 11,028 Site admin
    Answer ✓

    Generally you wouldn't want to loop over the results from a top level selector such as buttons(). It's job is to select the buttons needed, and store the results somewhere, so that the next level of methods can act on it (e.g. buttons().nodes().

    I've considered where it stores that information to be private, so those interfaces can change at times (as is the case here).

    What I would suggest you do is loop over the result of buttons().nodes() which will return a DataTable.Dom of the elements, and you can always loop over that. That is the public interface.

    In short, yes, I'm afraid that this is working as expected and a small change is needed in your code to use the publicly documented API for that action.

    Allan

Sign In or Register to comment.