Skip to content

Commit

Permalink
docs: Document how to change routing hash from the Python side. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Sep 6, 2023
1 parent 212bf16 commit 459193c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions website/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 459193c

Please sign in to comment.