File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ The server must respond with an HTML fragment to replace the `include-fragment`
44
44
45
45
If the URL fails to load, the ` include-fragment ` element is left in the page and tagged with an ` is-error ` CSS class that can be used for styling.
46
46
47
+ ### Events
48
+
49
+ Request lifecycle events are dispatched on the ` <include-fragment> ` element.
50
+
51
+ - ` loadstart ` - The server fetch has started.
52
+ - ` load ` - The request completed successfully.
53
+ - ` error ` - The request failed.
54
+ - ` loadend ` - The request has completed.
55
+
56
+ ``` js
57
+ const loader = document .querySelector (' include-fragment' )
58
+ const container = loader .parentElement
59
+ loader .addEventListener (' loadstart' , () => container .classList .add (' is-loading' ))
60
+ loader .addEventListener (' loadend' , () => container .classList .remove (' is-loading' ))
61
+ loader .addEventListener (' load' , () => container .classList .add (' is-success' ))
62
+ loader .addEventListener (' error' , () => container .classList .add (' is-error' ))
63
+ ```
64
+
47
65
### Options
48
66
49
67
Attribute | Options | Description
You can’t perform that action at this time.
0 commit comments