I noticed that when one wants to change the target of a dbc.Popover, one needs to to it twice for some reason:
from dash import (Dash, html, dcc, callback)
from dash import Input, Output, State, ctx, no_update
import dash_bootstrap_components as dbc
app = Dash(__name__)
app.layout = html.Div([
dbc.Button(id="button-1", children="I'm button 1"),
dbc.Button(id="button-2", children="I'm button 2"),
dbc.Button(id="button-3", children="I'm button 3"),
dbc.Popover(id="popover", body=True, children="Some text", is_open=True, placement="bottom")
])
@callback(
Output("popover", "target"),
Input("button-1", "n_clicks"),
Input("button-2", "n_clicks"),
Input("button-3", "n_clicks"),
)
def change_popover_target(n1, n2, n3):
if ctx.triggered_id == "button-1":
return "button-1"
elif ctx.triggered_id == "button-2":
return "button-2"
elif ctx.triggered_id == "button-3":
return "button-3"
return no_update
if __name__ == '__main__':
app.run_server(debug=True)