Comment

Comment by mg

I wonder what to think of htmx.

Their primary example is this:

    <button hx-post="/clicked" hx-swap="outerHTML">
        Click Me
    </button>
But that is rarely what I want to do when a button is clicked. My typical example would be I have list of - say - cars, and each car provides a button to delete it:

    <button onclick="carList.deleteItem(this)">
        Delete this car
    </button>
And then in deleteItem(), I typically:

    let item=getItem(e);
    if (!confirm(`Really delete ${item['name']}?`)) return;
    let item_id=getItemId(e);
    items.splice(item_id,1);
    document.getElementById('items').innerHTML = template(items);
Where "template" is a handlebars template.

Would htmx have anything to say about this?

parent mg 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton