scittle

rickheere 2023-08-03T18:03:45.564909Z

Hi, I didn't have time to try something out myself but I have an idea. With this library it's possible to run scripts from a script tag just like scittle but also from a tag with the _ (underscore) attribute. The code is applied to the tag it is found on. Would it be possible to have something like this in scittle as well?

rickheere 2023-08-04T08:06:12.395859Z

I have something working https://codepen.io/rickheere/pen/NWEJrpY

💡 2
rickheere 2023-08-04T08:07:28.869299Z

I needed to save my ref to the element on the window so I can get it back later. Can I improve that somehow?

borkdude 2023-08-04T08:57:04.724459Z

why not make the scittle attribute a function so you pass the ref:

(fn [{:keys [ref]}] ....)

rickheere 2023-08-04T09:32:29.494599Z

Yeah that works very well, I was not aware js/scittle.core.eval_string would return a function, I thought it would just read and execute code from a string 😅. Thank you!

rickheere 2023-08-04T09:33:03.056889Z

☝️ code is updated for who is interested.

👍 1
👍🏼 1
borkdude 2023-08-03T18:14:45.080749Z

Sure you can do this in user space with scittle already. Just write some JS interop and use scittle.core/eval_string

rickheere 2023-08-03T18:20:48.224079Z

Alright I'll try that out when I have some time, thanks.