Hi ! First I failed to find some answers on my issue, and that’s why I decided to ask my (rather) basic questions here.
I have a implemented multipage questionary. Depending the answer of a question answered in a previous webpage and stored into a dictionary through dcc.StoreI would like to generate a different dcc.link. The problem is that I need to refresh the webpage to make the link appears.
I spend quite a lot of time trying to solve this basic issue but I failed. Do you have any idea how to make this works ?
First, the data dictionary is declared as follow in the main.py piece of code :
import dash
from dash import dcc, html
import dash_bootstrap_components as dbc
app = dash.Dash(__name__, use_pages=True, external_stylesheets=[dbc.themes.BOOTSTRAP],suppress_callback_exceptions=True)
server = app.server
app.prevent_initial_callbacks='initial_duplicate'
app.suppress_callback_exceptions=True
app.layout = html.Div([
dbc.Container(
[dash.page_container],
fluid=True
),
dcc.Store(id='record_answers', storage_type='local', data = {})
])
if __name__ == "__main__":
app.run_server(debug=True)
On page 6 of my questionary, I generate and update the dcc.link as follow :
layout = html.Div(id='dynamic-link')
@callback(
Output('dynamic-link', 'children'),
Input('record_answers', 'data')
)
def update_link(data):
if 'consent' not in data:
return html.Div()
if data['consent'] == 'yes':
return dcc.Link('Next page', href='/page-7', style={'font-size': '20px'})
elif data['consent'] == 'no':
return dcc.Link('Access your personal report', href='/page-8', style={'font-size': '20px'})
Thanks in advance !