I use htmx together with the Django forms library.
Here is my template:
<table>
<tr hx-post="{{ object.get_absolute_url }}" hx-swap="outerHTML"
hx-trigger="changed">
<th>{{ object.leg.start }}</th>
<th>--></th>
<th>{{ object.leg.end }}</th>
<th>{{ object.leg.distance }}m</th>
<th>{{ object.leg.difficulty_verbose }}</th>
<td>{{ form.runner }} {{ form.runner.errors }}</td></tr>
</table>
Here is the created html:
<table>
<tr hx-post="/leg/155/Talfreunde/ %}" hx-swap="outerHTML" hx-trigger="changed">
<th>Schöneck</th>
<th>--></th>
<th>Mühlleithen</th>
<th>13400m</th>
<th>hard</th>
<td>
<select name="runner" required id="id_runner">
<option value="">---------</option>
...
</select>
</td>
</tr>
</table>
I want the <tr>
to act like a form.
I tried to find a way to tell hx-trigger to listen for the change event of the <select>
.
How to tell htmx to submit the data as soon as the select
was changed?
Background: This is a Relayrace and each leg will be a row in the table.