Content Loader
Style-agnostic content loader / suspense component.
Preview
Loading…
python
content_loader(loaded=False, placeholder='<p>Loading…</p>')Usage
views.py
python
from djust import LiveView
from djust.components import ContentLoader
from django.utils.safestring import mark_safe
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = ContentLoader(loaded=False, placeholder=mark_safe('<p>Loading…</p>'))my_template.html
django
{{ component }}Parameters
| Name | Type | Default |
|---|---|---|
| loading_event | str — the event your server pushes to it | 'data_loaded' |
| loaded | bool | False |
| placeholder | str | '' |
| content | str | '' |
| error | str | '' |
| error_event | str — renames the event; identity is `name` | '' |
| custom_class | str | '' |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.content_loader | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 2 of this component's classes at line 1767, 1768. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |