You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: code/go/site/static/md/examples/animations.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,13 +67,14 @@ Building on the last example, we can fade in the new content the same way, start
67
67
One of the nice features for reactivity is to show a spinner when a request is in flight. On any element that is using backend actions you can add a `data-indicator` attribute to show a spinner when the request is in flight. This can be done like so:
Copy file name to clipboardExpand all lines: code/go/site/static/md/reference/plugins_backend.md
+29-26Lines changed: 29 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,6 @@
4
4
5
5
A set of plugins that allow for the integration of any backend service that supports SSE with Datastar.
6
6
7
-
## Attribute Plugins
8
-
9
-
Request for data from the server via SSE and merge with the page.
10
-
11
7
## Action Plugins
12
8
13
9
### `$get`, `$post`, `$put`, `$patch`, `$delete`
@@ -20,7 +16,24 @@ Makes an HTML_VERB request to the server and merges the response with the curren
20
16
21
17
Every request will be sent with a `{datastar: *}` object containing the current store (except for store keys beginning with an underscore). When using `$get` the store will be sent as a query parameter, otherwise it will be sent as a JSON body.
22
18
23
-
## Datastar SSE Event
19
+
#### Options
20
+
21
+
The actions above take a second argument of options.
22
+
23
+
The `onlyRemoteSignals` option determines whether to only send remotely viewable store values (defaults to `true`).
24
+
25
+
The `headers` option is an object containing headers to send with the request.
@@ -57,7 +70,7 @@ Additional `data` lines can be added to the response to override the default beh
57
70
|`data: useViewTransition true`| Whether to use view transitions when merging into the DOM. Defaults to `false`. |
58
71
|`data: fragments`| The HTML fragments to merge into the DOM. |
59
72
60
-
###datastar-merge-signals
73
+
#### `datastar-merge-signals`
61
74
62
75
```go
63
76
event: datastar-merge-signals
@@ -67,7 +80,7 @@ data: signals {foo: 1234}
67
80
68
81
The `datastar-merge-signals` event is used to update the store with new values. The `onlyIfMissing` line determines whether to update the store with new values only if the key does not exist. The `signals` line should be a valid `data-store` attribute. This will get merged into the store.
69
82
70
-
###datastar-remove-fragments
83
+
#### `datastar-remove-fragments`
71
84
72
85
```go
73
86
event: datastar-remove-fragments
@@ -83,7 +96,7 @@ data: paths foo.bar 1234 abc
83
96
84
97
The `datastar-remove-signals` event is used to remove signals that match the provided paths from the store.
85
98
86
-
###datastar-execute-script
99
+
#### `datastar-execute-script`
87
100
88
101
```go
89
102
event: datastar-execute-script
@@ -97,22 +110,22 @@ The `datastar-execute-script` event is used to execute JavaScript in the browser
Show a spinner when the request is in flight. The `data-fetch-indicator` attribute should be a CSS selector to the element(s). When the attribute is present, the element will be hidden when requests are not in flight and shown when they are.
124
+
The `data-indicator` attribute sets the value of the provided signal name to `true` while the request is in flight. This signal can be used by other attributes to show a loading spinner, disable a button, etc.
112
125
113
-
The `$isFetching` action returns a computed value that allows you to easily react to the state of the indicator.
126
+
Note that elements using the `data-indicator` attribute ***must*** have a unique ID attribute.
114
127
115
-
### Replace URL
128
+
### `data-replace-url`
116
129
117
130
```html
118
131
<div
@@ -127,13 +140,3 @@ Replaces the URL in the browser without reloading the page. The value can be a r
0 commit comments