@antony66 wrote:
Hi everyone!
I’ve recently discovered that if I create a multipage app according to https://dash.plotly.com/urls and some of my apps pages contain a callback with multiple outputs, it doesn’t work.
Here is my example code:
app.py:
import dash app = dash.Dash(__name__) server = app.server app.config.suppress_callback_exceptions = True
index.py:
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app from apps import master, detail app.layout = html.Div([ dcc.Location(id='url', refresh=False), html.Div(id='page-content') ]) @app.callback(Output('page-content', 'children'), [Input('url', 'pathname')]) def display_page(pathname): if pathname == '/': return master.layout elif pathname == '/detail': return detail.layout else: return '404' if __name__ == '__main__': app.run_server(debug=True)
master.py:
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app items = [f'item{i}' for i in range(1,10)] layout = html.Div([ html.H3('Master'), html.Div([ dcc.Link(children=item, href=f'/detail?id={item}') for item in items ], id='master-items'), ])
detail.py that works:
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app layout = html.Div([ html.H3(id='detail-title'), html.H3(id='detail-title2'), ]) @app.callback(Output('detail-title', 'children'), [Input('url', 'search')]) def update_detail_title(query): return 'aaaa ' + query
detail.py that doesn’t work:
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from app import app layout = html.Div([ html.H3(id='detail-title'), html.H3(id='detail-title2'), ]) @app.callback([Output('detail-title', 'children'), Output('detail-title2', 'children')], [Input('url', 'search')]) def update_detail_title(query): return 'aaaa ' + query, 'bbb'
Isn’t it a bug?
Posts: 3
Participants: 2