@jwillis0720 wrote:
Hello everyone,
I am trying to initally populate a dropdown in my layout with a cookie. If a user has populated the dropdown with 20 items from their last visit, I would like them to be able to pickup where they left off. I am storing my cookies in the callback context as specified here.
@app.callback(Output('dropdown_container', 'value'), [Input('someothercomponent', 'clickData')]) def update_dropdown(clickData): #do something dash.callback_context.response.set_cookie( 'mycookie', pickle.dumps(values)) return values
I also have a dynamically loaded layout on refresh.
def get_dropdown(): ...setup options from data... dd = dcc.Dropdown( id='dropdown_container', options=countries+provinces+state+counties, value=['worldwide', 'COUNTRY_US:NONE', 'STATE_New York:US'], multi=True, style={'position': 'relative', 'zIndex': '3', 'font-size': '75%'} ) return dd def serve_dash_layout(): return html.Div(id='root-container', children=get_dropdown()) server = flask.Flask(__name__) app = dash.Dash(server=server, meta_tags=get_meta()) app.layout = layouts.serve_dash_layout
Because the function
get_dropdown()
which is underserve_dash_layout
creates the initial dropdown default values, I was wondering if it could have access to themycookie
that I setup in the callback the nexttime the user comes to my app. What global variables does serve_dash_layout have access to?Thanks so much,
J
Posts: 1
Participants: 1