java - How to generate edit modals for each element in the model? -
i'm trying use thymeleaf generate edit , delete modals each element in model in modelandview
using th:each
.
the modals indeed created , have unique ids based on id field of elements. problem have none of values elements parsed input
s enable user see current values.
they there because view has table displays each element's values along anchors toggle modals.
here's example code of how i'm doing it:
<div th:each="f : ${foos}" th:id="um- + ${f.id}" class="modal fade" tabindex="-1" role="dialog"> ... <form role="form" th:action="@{/foo/update}" th:object="${foo}" th:method="post"> <input type="hidden" th:field="*{id}" th:value="${f.id}"/> <fieldset class="form-group"> <label for="bar">bar</label> <input th:field="*{bar}" th:value="${f.bar}" class="form-control" id="bar" type="text" placeholder="bar"/> </fieldset> ... </form> ... </div>
how generate edit modals each element in model? i'm not sure why thymeleaf unable values of fields model elements.
that's not great approach actually. in addition not working, doing using loop creates n
modals collection.
the solution worked best provide single modal populated , submitted ajax calls.
this no-frills spring boot app has relavant code.
Comments
Post a Comment