I have a thymeleaf page that shows database content (persons) in a table.
<tr id="tableBody">
<td th:text="${row.id}"/>
<td th:text="${row.firstname}"/>
<td th:text="${row.lastname}"/>
<td>
<button data-toggle="modal" data-target="#editModal" th:data-row="${row}">DEL</button>
</td>
</tr>
The last column should be a button that deletes the row. But prior, show a modal dialog with the data being deleted.
Question: how can I pass the the full row person object to a modal dialog?
I started as follows, but I'm missing how I could actually pass the person object from the clicked row into the modal dialog as an object (so that I can show the person fields in the modal dialog again).
The following is kind of pseudo code:
<div class id="editModal" ...>
<div class="modal-body">
<div class="modal-body">
You are about to delete: <div th:text="${row.firstname}"/> <div th:text="${row.lastname}"/>
<form action="#" th:action="@{/delete/{id}" th:object="${row}" method="delete">
<input type="text" hidden="true" th:field="${row.id}">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary" th:href="@{/delete/{id}(id=${row.id})}" th:method="delete">Remove</button>
</div>
</div>
</div>