Objective: I would like to pop an Alert component if a condition occurs (i.e no data from URL pathname) otherwise render the app
What I've tried so far
app.layout = dbc.Container([
dbc.Alert([...], id='alert', is_open=False),
dbc.Container([rows & columns (all visuals are here)], id='page1')
])
@app.callback(
[Output('alert', 'is_open'),
Output('store-component', 'data'),
Output('page1', 'children')],
Input('url', 'pathname')
)
def extract_path_from_url(pathname):
if pathname name contains ... :
store the dataset in the Store component and **DONT SHOW THE ALERT BUTTON**
else:
**SHOW THE ALERT BUTTON** and that's it
... other callbacks generating the visuals based on the store-component ...
This didn't work, is there a proper way to achieve this ?
EDIT: Latest try:
this is my updated callback and layout. So far it works fine when the condition is True , the Alert component doesn't display and everything displays fine. The problem is when the condition is false, the Alert message shows successfully but the we can see the graphs being empty. I want to hide them or not render them at all...
app.layout = dbc.Container([
dbc.Alert([...], id='alert', is_open=False),
dbc.Container([rows & columns (all visuals are here)], id='container')
])
@app.callback(
[Output('alert', 'is_open'),
Output('store-component', 'data'),
Output('container', 'style')],
Input('url', 'pathname')
)
def extract_path_from_url(pathname):
if pathname name contains ... :
return dash.no_update, data, dash.no_update
else:
return True, dash.no_update, {'display': 'none'}

