We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make triggered_id available clientside like in #1240
It would be convenient to include triggered_id with clientside callbacks as well, so you could get the id simply by:
triggered_id
from dash import Dash, html, Input, Output app = Dash(prevent_initial_callbacks=True) app.layout = html.Div([ html.Button("Button 1", id="btn1"), html.Button("Button 2", id="btn2"), html.Button("Button 3", id="btn3"), html.Div(id="log") ]) app.clientside_callback( """ function(){ const triggered_id = dash_clientside.callback_context.triggered_id return "triggered id: " + triggered_id } """, Output("log", "children"), Input("btn1", "n_clicks"), Input("btn2", "n_clicks"), Input("btn3", "n_clicks"), ) if __name__ == '__main__': app.run_server()
And with pattern matching callbacks you can access the dict id like this:
from dash import Dash, html, Input, Output, ALL app = Dash(prevent_initial_callbacks=True) app.layout = html.Div([ html.Button("Button 4", id={"type": "btn", "index":4}), html.Button("Button 5", id={"type": "btn", "index":5}), html.Button("Button 6", id={"type": "btn", "index":6}), html.Div(id="log") ]) app.clientside_callback( """ function(){ const triggered_id = dash_clientside.callback_context.triggered_id return "triggered button index # " + triggered_id.index; } """, Output("log", "children"), Input({"type":"btn","index":ALL}, "n_clicks" ) ) if __name__ == '__main__': app.run_server()
@alexcjohnson I have a PR ready to go if you would like it 🙂
The text was updated successfully, but these errors were encountered:
I was just looking for this property and instead ended up with this workaround. triggered_id would be nice!
window.dash_clientside.callback_context.triggered[0].prop_id.split('.')[0]
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
Make triggered_id available clientside like in #1240
It would be convenient to include
triggered_id
with clientside callbacks as well, so you could get the id simply by:And with pattern matching callbacks you can access the dict id like this:
@alexcjohnson I have a PR ready to go if you would like it 🙂
The text was updated successfully, but these errors were encountered: