Multiple callbacks for an output

Thanks! Did you test it? I added support for @callback after posting the previous answer. I haven’t had the time to play with multipage yet though.

1 Like

No! Good to know! I’ll test and revert.

I tried and I get the Duplicate Callback Output error:
:rescue_worker_helmet:
Duplicate callback outputs
10:29:32 PM
In the callback for output(s):
img_backtest.src
Output 0 (img_backtest.src) is already in use.
Any given output can only have one callback that sets it.
To resolve this situation, try combining these into
one callback function, distinguishing the trigger
by using dash.callback_context if necessary.

I then tried to import “callback” from dash_extensions.enrich => different error:
Cannot read properties of undefined (reading ‘src’)
Though to be clear: despite the error message, the callback using the first declared input (“dashboard_asset”) in the layout works perfectly, the error arises on the callback on the 2nd declared input (“dashboard_asset-test”).

Callbacks definition for clarity:

@callback(
Output(‘img_backtest’, ‘src’),
Input(ThemeSwitchAIO.ids.switch(“theme”), “value”),
Input(‘dashboard_date’, ‘date’),
Input(‘dashboard_asset-test’, ‘value’),
)
def update_backtests_fig_test(toggle, dashboard_date, dashboard_asset):

return im

@callback(
Output(‘img_backtest’, ‘src’),
Input(ThemeSwitchAIO.ids.switch(“theme”), “value”),
Input(‘dashboard_date’, ‘date’),
Input(‘dashboard_asset’, ‘value’),
)
def update_backtests_fig(toggle, dashboard_date, dashboard_asset):

return im

Thank you for this information, is was very helpful.

I have an issue that i don’t know if it matters. When I execute plolty, the console put three times the message: Dash is running on http://127.0.0.1:8050/

Thanks!!

You have to import the ‘callback’ from de DashProxy app, put @app.callback(…) and maybe it will work.

Thank you very much!

best work around solution is using tabs instead of div or wrap up your changeable element with button where the div will be update every time you change between the dynamic buttons.
I may not explain it well. but it removed the need of re-render to the same output twice