The behavior I expect:
- Point app.layout to some function “foo”
- Generate layout by calling “foo”
- Have a callback at some point update the URL
- “foo” is called to regenerate the layout
Frustrating this works in Chrome but in IE the original layout is used and foo is not called on step 4.
Here is an example, I have simplified my code by using global variables but in my real web-site I am basing this on cookies:
import time
# Third Party Library
import flask
from dash.exceptions import PreventUpdate
## Dash and Plotly Libraries
import dash
import dash_core_components as dcc
import dash_html_components as html
url_update = False
def get_layout():
children = [dcc.Location(refresh=True, id='URL_OUTPUT'),
dcc.Location(refresh=True, id='URL_INPUT')]
global url_update
if flask.has_request_context() and url_update:
url_update = False
children.append('Redirected')
else:
children.append('Original URL')
return html.Div(children)
# App
app = dash.Dash(__name__)
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = get_layout
@app.callback(output=dash.dependencies.Output('URL_OUTPUT', 'pathname'),
inputs=[dash.dependencies.Input('URL_INPUT', 'pathname')])
def login_callback(pathname):
if pathname is None:
raise PreventUpdate
time.sleep(10)
if pathname != '/redirect':
global url_update
url_update = True
return '/redirect'
raise PreventUpdate
if __name__ == '__main__':
app.run_server(port=8050, host='0.0.0.0')
In this example using Chrome the page updates to “redirected” after 10 seconds, but for IE even though the URL is updated to “/redirect” the page still only says “Original URL”