many thanks. i managed to hack it up this morning using dcc.Location and ripping the query string … like this:
@app.callback([Output(‘search_text’, ‘value’),
Output(‘search_text’,‘n_submit’)],
[Input(‘url’, ‘pathname’),
Input(‘url’, ‘search’)
])
def display_page(pathname ,search):
if pathname == “/search”:
return search.replace(’?’,’’), -1
raise PreventUpdate
So now when the link is “www.myapp.com/search?London” … the above code will will set my [search_text.value] to be ‘London’ … not so hard …
The real issue i was having was getting it to “trigger” my fairly complex event that lies behind the search. Since its one of those multi-input event ‘funnels’ (user might have clicked and of n buttons, plus lots of state inputs etc) that everyone has to use to work around the “single output per component value” thing … (below)
@app.callback([
Output(‘q-ids’, ‘children’),
Output(‘question_header’, ‘children’)
],
[
Input(‘entity_selected’, ‘children’),
Input(‘search_text’,‘n_submit’),
Input(‘map_questions’,‘children’),
Input(‘polar_button_group’,‘children’),
Input(‘questions_curated_selected’,‘children’),
#Input(‘auto_topic_filter’,‘value’),
],
[
State(‘search_text’,‘value’)
])
that means that inside the callback event i have to use Context to work out what has really triggered the callback …
ctx = dash.callback_context.triggered[0]
followed by lots of if . .else …
BUT that ctx is of course missing when you serve up the whole page from scratch.
So i had to write some logic to drive the special case of no Context …