-
-
Notifications
You must be signed in to change notification settings - Fork 49
Conversation
This PR requires a fix in plotly/dash-renderer#54 |
Usage would be:
|
And you can try it out with:
|
Could someone from @plotly/dash please review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well for the particular fix this is 💃
Is there an issue for the more complete solution of giving users the ability to inspect callback inputs for meta data?
I don't think this is going to be the last time we need a stopgap to work around the limitation of only getting values in a callback. It would be nice to avoid similar "needs to get done now" type stopgaps in the future.
There isn't, but there definitely should be a greater discussion around this. |
n_clicks_previous won’t work unless dash-renderer is handling - it’ll always just be n_clicks - 1. Instead, we could attach a timestamp to the event and use that for comparison. This is a stopgap until we serve this property for all components in the framework itself.
@chriddyp Is there a possibility to make The way you specified in example about explicitly setting it to Simply making that property equal to |
@radekwlsk This will eventually be the case in plotly/dash#288. |
@chriddyp Thanks for providing this workaround. I have implemented this to determine which button was clicked in my app. But it starts to crush with memory limitation complaints after it running a while on the server. I don't know how |
Have there been any updates on this? E.g. for cases where there is a button in a callback together with other elements? Could the n_clicks_timestamp also be applied to dcc-core-components like Upload? |
This PR adds a
n_clicks_timestamp
property to alldash_html_components
properties.This can be used to determine which element was clicked on if multiple elements are Inputs in a callback.
This is just a workaround. In the future, we should enable this behaviour through something more abstract in
dash-renderer
and the@app.callback
signature to handle this for all components and all of their properties.Determining “which button was clicked” in a callback is the most common use case, so we’ll just support it through this
n_clicks_timestamp
property for now.