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
data: elements <script>console.log('Here')</script>
365
+
```
366
+
</details>
367
+
368
+
<details>
369
+
<summary>Full Example (all options)</summary>
370
+
371
+
```
372
+
event: datastar-patch-elements
373
+
id: 123
374
+
retry: 2000
375
+
data: mode append
376
+
data: selector body
377
+
data: elements <script type="application/javascript" data-effect="el.remove()">console.log('Here')</script>
378
+
```
379
+
</details>
380
+
381
+
### Parameters
382
+
383
+
-**script**: One or more lines of JavaScript.
384
+
385
+
### Options
386
+
387
+
| Parameter | Type | Default | Description |
388
+
|-----------|------|---------|-------------|
389
+
|`autoRemove`| boolean |`true`| Removes the script tag after executing |
390
+
|`attributes`|[]string | - | Attributes to add to the script tag |
391
+
392
+
### Implementation
393
+
394
+
***Must*** call `ServerSentEventGenerator.send` with event type `datastar-patch-elements`, sending a `script` tag containing the JavaScript to execute. If `autoRemove` is `true`, `data-on-load="el.remove()"` must be added to the `script` tag. If `attributes` exist, they must be added to the `script` tag.
395
+
396
+
**Data format** (only include non-defaults):
397
+
-`selector body\n`
398
+
-`mode append\n`
399
+
-`elements SCRIPT_TAG\n`
400
+
401
+
---
402
+
341
403
## `ReadSignals`
342
404
343
405
`ReadSignals` parses incoming signal data from the browser into backend objects.
0 commit comments