Closed cloudgrayau closed 3 weeks ago
No, but there is data-on-load
, which is triggered whenever the element is loaded into the DOM. You can use this if you need to trigger some JS after an element has been swapped in. See the docs on using external scripts.
<div data-on-load="myfunction()"></div>
Is there any reason you can’t fetch the content via Spark? This might work, but it’s generally advised to avoid such trickery when at all possible.
ds.applyPlugins(element)
Yep, perfect. Thanks.
It appears with point 2, that the AJAX fetched content already triggers spark, which was my mistake.
Support Request
Hello,
I am just looking at possibly replacing Sprig with Spark on a website I am developing. I know that most of these will rely on the actual Datastar framework, but I can't find any documentation on either of them on the Datastar docs.
1) Is there a JavaScript afterSwap 'event' equivalent, similar to:
2) I also have some custom AJAX running. Is there any option to run the returned HTML through Spark? Similar to the HTMX equivalent:
Thanks,
Plugin Version
No response