← Back to context

Comment by floydnoel

2 days ago

are event handlers possible? neither the Github repo nor the linked page showed an example of a button or form submission.

It looks like this is focused on server rendering HTML, no client-side runtime or anything like that.

I don't see any used of a `Script()` function or similar in the example apps, though you could always chunk some JS in a public directory and link it in the HTML.

They do have a starter example that uses HTMX. That'd be my go-to as well for a tool that's sticking with server rendering HTML.

gomponents is just a glorified string builder, so it's more or less like writing HTML in Go that gets output from the server. So you put event handlers on your elements like you normally would, write scripts and include JS like you normally would, etc.

That said, there's gomponents-htmx [0] for easy integration with HTMX.

[0]: https://github.com/maragudk/gomponents-htmx

This is basically a HTML templating library. It's server side only. Or do you mean event handlers in the HTML attributes?