yts61
yts61

Reputation: 1599

Plotly Dash Share Callback Input in another page with dcc.Store

i have a 2-page app, on the first page (app.py), i use dcc.Store to store a value in the session cache, and then trying to load this data in the 2nd page (app2.py), and show it as html.H1.

Here is my code in page one:

dcc.Store(id='session', storage_type='session'), 

then my callback on this page is:

@app.callback(Output('session', 'data'),
              [Input('q1', 'value')])
def q1_value(q1):
     return {'answer1value': q1}

while "q1" is a value from my radioitem.

But when i run this app, nothing is shown up in this H1. I have spent many hours fixing this but fail, would anyone please help ?

Upvotes: 3

Views: 3564

Answers (1)

user14175248
user14175248

Reputation:

put your

dcc.Store(id='session', storage_type='session'),

onto the app.py, not page1.py, under the

app.layout = html.Div([....])

then your value will be stored here, and can be called from other pages.

Upvotes: 5

Related Questions