How to know which button fired the callback

I got several buttons. with index 1,2,3,4.
use pattern-matching ALL(not Match)
the inputs of the fired callback got the list of n_clicks of the four buttons.
How to know which button fired the callback.

Please take a look in the docs, more specifically in the section Determining which Input has fired with dash.callback_context.

But with the pattern-matching “ALL”, the value type of dash.callback_context.inputs or dash.callback_context.triggered is a list which contains the information of the four buttons.
Is there any way to know which button(which id or index like the pattern-matching “MATCH”) fired the callback?

callback_context.triggered should work, unless you are doing something else in the layout (like rewritting the buttons in a callback or something).

Would you mind sharing a minimal example?

In a pattern matching setup, where the id is a dictionary, the context will return the id dict that is attached to the object that triggered. So you can you check whether or not a key exists and whether or not it is the correct value you are looking for.

1 Like