From 459193cbec64272e9bc60efdf55e063ee0051fa8 Mon Sep 17 00:00:00 2001 From: Martin Turoci Date: Wed, 6 Sep 2023 14:35:44 +0200 Subject: [PATCH] docs: Document how to change routing hash from the Python side. Closes #375 --- website/docs/routing.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/website/docs/routing.md b/website/docs/routing.md index dcb0d43b36..137ad29766 100644 --- a/website/docs/routing.md +++ b/website/docs/routing.md @@ -59,6 +59,19 @@ The components that support setting a location hash are: - `ui.tab()` - `ui.breadcrumb()` +### Setting the location hash from python + +To set the hash route explicitly without command invocation as described above, `ui.meta_card` is the way to go. + +```py +# If meta_card does not yet exist, create one. If it does, skip this line. +q.page['meta'] = ui.meta_card(box='') +# Redirect to a hash. +q.page['meta'].redirect = '#widgets' +# Apply the change in browser. +await q.page.save() +``` + ### Getting the location hash To get the location hash, read `q.args['#']` (a string). If the route in the browser's address bar is `/foo/bar#baz/qux`, `q.args['#']` is set to `baz/qux`.