-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single Page App ("SPA") URL / Multi Page Support - Proposal and Development Preview #77
Comments
This seems promising :) Some feedback... I just tried this out in the context of what is going to be a reasonable sized collection of separate dashboards. The difficulty I'm having incorporating this approach into my current code is getting all the callbacks to be applied to the layout fragment that corresponds to each distinct route. For example, in your above code, how would you apply callbacks to elements in the layout that display_path returns? The tricky aspect seems to be that layout has to be registered before a callback can be applied to any contained elements. It's possible to have at least one initial complete layout registered along with callbacks, however if a page load overwrites this based on a particular route pattern, then you wind up with the initial layout being rendered briefly then being updated with the route corresponding to the URL. (also, it the same problem of applying callbacks still applies to all routes other than the one initial one). Perhaps I'm missing an obvious way around this problem though? |
Ah, perhaps it's as simple as adding |
The main gotcha is that you have to define all of the callbacks upfront and that you have to set |
I have merged this into |
Great, thanks heaps for that @chriddyp. |
Hello Dash Community!
I just published 2 new components under the pre-release channel that enable multi-page support.
dash_core_components.Location
component.Location
represents the URL bar in the browser. Thepathname
property updates thepathname
of the browser, refreshing the page ifrefresh=True
.dash_core_components.Link
component.Link
is likehtml.A
except that it updates theLocation
'spathname
directly, without refreshing the page (refresh=False
). Likehtml.A
, it takeshref
as a component. It doesn't render any markup itself, it just adds an "click" handler to whateverchildren
were passed into it.With these two components, we can make single-page apps with multiple URLs in Dash. A "single-page app" means that the pages update without doing an entire page refresh.
Here is a really eximple example:
You can try this out with
I'll keep this in the prerelease channel for the next week or so before adding it to
0.5.3
and including it in the documentation.I think this is a pretty good solution to handling multiple URLs for now.
Happy to field any feedback on this :)
The text was updated successfully, but these errors were encountered: