mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Documentation (#6200)
* vim backup files to be ignored * added tip about using document$ observable
This commit is contained in:
parent
e2fc46a299
commit
6a9b685405
@ -54,6 +54,29 @@ extra_javascript:
|
||||
- javascripts/extra.js
|
||||
```
|
||||
|
||||
!!! tip "Make sure the page is fully loaded"
|
||||
|
||||
It is likely that you will want to run your JavaScript code only
|
||||
once the page has been fully loaded by the browser. This means
|
||||
installing a callback function subscribing to events on the
|
||||
`document$` observable exported by Material for MkDocs.
|
||||
Using the `document$` observable is particularly important if you
|
||||
are using [instant loading] since it will not result in a page
|
||||
refresh in the browser - but subscribers on the observable will be
|
||||
notified.
|
||||
|
||||
``` javascript
|
||||
document$.subscribe(function() {
|
||||
console.log("Page loaded.") // or whatever it is you want to do
|
||||
})
|
||||
```
|
||||
|
||||
`document$` is an [RxJS Observable] and you can call the `subscribe()`
|
||||
method any number of times to attach different functionality.
|
||||
|
||||
[instant loading]: setup/setting-up-navigation.md/#instant-loading
|
||||
[RxJS Observable]: https://rxjs.dev/api/index/class/Observable
|
||||
|
||||
## Extending the theme
|
||||
|
||||
If you want to alter the HTML source (e.g. add or remove some parts), you can
|
||||
|
Loading…
Reference in New Issue
Block a user