✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to know which component is clicked?

Two date range picker and a button are combined in the Input. I would like to know which component is clicked, button or date? If the button is clicked it should go inside the if(clicks) or if a date is selected in date range picker then it should go inside the if(st_date). Or is there a way to reset the n_clicks to zero each time when the user clicks the button? There is no option for me to define them in another callback as I am updating the graph when any of my input is changed.

@app.callback(Output('bar-graph', 'figure'),
              [Input('refresh-button', 'n_clicks'),
               Input('date-picker-range', 'start_date'),
               Input('date-picker-range', 'end_date')])
def update_Graph(clicks, st_date, ed_date):
         do something
         do something

The dash.callback_context might help you here. It is explained within the Part 7. FAQs & Gotchas . Have a look at the Question: How do I determine which Input has changed?

1 Like