Get IDs from List of Items by Class in HTMX

Viewed 100

We have a number of rows in a table, and each table row has a HTML id="itemid-1234" etc.

What we would like to do, is to find a way of selecting all of those tr's which have a class of "selected" and be able to pass all those id's to our PHP/Ajax call script. Relatively trivial with a direct jQuery Ajax call, but haven't seen anything with HTMX.

1 Answers

I see two ways of solving this.

Solution 1: <form> with hidden inputs

You create a form around the table and insert a hidden input in each <tr>

Solution 2: event configRequest

You use the configRequest event and some JS to collect the data which you want to sent.


BTW: The htmx community is not very active here at Stackoverlfow up to now. The next time please sent the URL of your question to the htmx discord channel. This time I did this.

Related