Add Edit buttons to "Delete Row" example #3714
|
Hi everyone! I'm trying to add an Edit button for each row in the HTMX delete row example. Unfortunately, I'm running into some issues and haven't been able to get it working correctly. One specific problem I'm facing is that the I'd really appreciate any guidance or suggestions you might have! Thanks in advance! |
Replies: 1 comment
|
<tbody hx-confirm="Are you sure?">
<tr>
<td>
<button class="danger" hx-delete="/row/1">Delete</button>
<button hx-confirm="unset" hx-get="/row/1/edit">Edit</button>
</td>
</tr>
</tbody>That keeps the confirmation on |
hx-confirmis an inheritable attribute in htmx, any descendant that issues a request picks it up from the nearest ancestor that sets it, which is exactly why putting it ontbodyapplies it to every button underneath, including the Edit button you don't want confirmed. You don't need to repeat or restructure anything, htmx has a documented escape hatch for exactly this: sethx-confirm="unset"on the specific element you want to opt out, and inheritance stops there for that attribute.T…