biff

macrobartfast 2024-07-09T06:31:41.881049Z

How do I call a js function after an htmx element gets swapped in (afterSwap)?

lyall 2024-07-10T08:48:29.302599Z

I'm not familiar with flowbite, so can't say if this is a proper solution, but you could listen for an htmx:afterRequest event for the button in question, then call initFlowbite() when it's received. If you're using hyperscript it could be something like <button [...] _="on htmx:afterRequest js initFlowbite() end">...</button>

lyall 2024-07-10T08:52:20.984249Z

or hm maybe you need it to be htmx:afterSwap and listen for the event on the huge list being swapped in, again not sure exactly what the needs of flowbite are

macrobartfast 2024-07-10T18:13:32.426599Z

Ah, ok… the hyperscript htmx was what I was missing… this could be a game changer for me as it opens up all the htmx functionality.

macrobartfast 2024-07-10T18:16:48.622929Z

@me1621 This worked perfectly!! Thank you!

lyall 2024-07-10T23:15:53.600739Z

Glad to hear! I’ve only just started playing with hyperscript myself, but I’ve been pretty pleased with it so far. Btw I’d recommend the https://hypermedia.systems/client-side-scripting/ of the htmx https://hypermedia.systems/ book if you want a good intro to the topic. The whole book is worth a read really (although you can probably skip the mobile app/hyperview section unless you care about that)

lyall 2024-07-09T07:23:27.190879Z

you'd probably need to add an event listener to the htmx:afterSwap event kinda like this example (except not the config event ofc) https://hypermedia.systems/tricks-of-the-htmx-masters/#using-the-htmx-configrequest-event

macrobartfast 2024-07-10T04:04:23.836429Z

As usual, I should have just stated my actual problem. A button replaces the main area of my SPA with a huge list… and of course the Tailwind/Flowbite library has already loaded. So I need to run initFlowbite() after the list swaps into the target div, so it’s all styled correctly. Your advice may be the same, but I should have just asked this initially.

jf 2024-07-09T14:25:51.933009Z

How does biff determine whether to print an email to the console vs actually sending it? I just registered with mailersend, and have MAILERSEND_FROM and MAILERSEND_API_KEY assigned in config.env. I've restarted app, but I still get the sign-in link printed to the console.. and mailersend is also saying that no emails got sent. If I use curl however (as per https://www.mailersend.com/features/email-api), I am able to trigger a send (and now mailersend reports 1 sent and delivered email), so it looks like it's not an issue with my mailersend setup.

jf 2024-07-09T14:41:21.351529Z

nvm I decided to do a search in the source.. and came across the note in home.clj about needing to have keys for both MailerSend... and reCAPTCHA as well. Will work on that, and then come back if I still have issues.

oλv 2024-07-09T14:46:26.733659Z

fwiw i also ran into this issue

oλv 2024-07-09T14:46:34.491229Z

might be worth printing a warning or something

jf 2024-07-09T14:46:55.379129Z

as in u only had MailerSend set up but not reCAPTCHA?

oλv 2024-07-09T14:47:02.664309Z

yeah

oλv 2024-07-09T14:47:17.538639Z

i did implement that warning a while back, mb i forgot to pr it or something

🤔 1
jf 2024-07-09T14:47:19.484839Z

yeah, it isnt exactly clear

jf 2024-07-09T14:47:49.526419Z

if you could check that'd be great

oλv 2024-07-09T15:03:31.367389Z

I threw the code away cus i thought it was dumb and wouldn’t be useful to other people 🤦🏻‍♂️

🥹 1
oλv 2024-07-09T15:05:14.934839Z

might be a good pr for u tho :^)

jf 2024-07-09T15:14:13.494839Z

🙂 haha

2024-07-09T16:15:08.164089Z

😉 there is this already: https://github.com/jacobobryant/biff/blob/c0cf90a074ed3595d7c9cd62b7480bba437cc66d/starter/src/com/example/email.clj#L80. Would tweaking that in some way solve the problem? e.g. making it more prominent with ascii art or something. If not, another option could be to add an info box to the web app UI (maybe just on the landing page?) that lists out the config keys you still need to add.

jf 2024-07-10T04:47:28.810419Z

ah, thank you for that! I saw that line in my early days, but have since forgotten. After that, it's been all about looking for the verify link if I look, and skipping the rest of the text of the email as "part of the template" in my mind. Yes, it would be good to make it more prominent in some way.

👌 1