【发布时间】:2019-02-06 20:57:52
【问题描述】:
编辑:
刚刚发现我需要JS。请帮帮我。我有一个th:attr="data-object-id=${department.id}" 存储部门ID,我需要将其放入<input id="ids" name="ids" type="text" class="validate"> 的模态中。
JS 或 JQuery 会是什么样子?我正在尝试编写,但始终为 null 或未定义。
<tr th:each="department : ${departments}">
<td class="dep_id" th:text="${department.id}">1</td>
<td th:text="${department.name}"></td>
<td>
<div class="dep_edit">
<a class="settings_dep" th:href="@{'/departments/' + ${department.id} + '/'}"><i class="material-icons">settings</i></a>
<a class="edit_dep modal-trigger" href="#modal3" th:attr="data-object-id=${department.id}"><i
class="material-icons">edit</i></a>
<form method="post" th:action="@{'/departments/' + ${department.id} + '/delete'}" class="inline">
<button type="submit" value="" class="link-button delete_dep">
<i class="material-icons">delete</i>
</button>
</form>
</div>
</td>
</tr>
<div id="modal3" class="modal modal-departments">
<div class="modal-dep modal-content">
<h4>Update Department</h4>
<a href="#" class="dep-modal-close modal-close"><i
class="material-icons icon_close">close</i></a>
<p>Update Department name</p>
</div>
<div class="dep-modal">
<form id="dep-update" class="col s12" th:action="@{'/departments/update'}" method="POST">
<div class="row-modal-dep">
<div class="input-field col s6">
<input id="depName" name="name" type="text" class="validate">
<input id="ids" name="ids" type="text" class="validate">
<label for="name">Department Name</label>
<i class="edit-dep-marker material-icons prefix">mode_edit</i>
</div>
</div>
</form>
<div class="modal-footer">
<input class="modal-close waves-green green btn-dep btn" type="submit" form="dep-update">
</div>
</div>
</div>
我需要将部门的 ID 值提供给 MODAL,以便我可以更新它
我的部门课程很简单。只有 ID 和姓名;
【问题讨论】:
-
你能把你的问题说得更清楚吗?
-
编辑问题并添加图片
-
让我们展示你的班级
Department或你的Java代码(不仅仅是查看层代码) -
这是一个简单的类,包含字段:id、name;
-
实现这一目标的一个快速技巧是在您的 html 页面上创建一个隐藏的 html 元素,然后使用其在模式上的 id 获取该 html 元素的值。
标签: javascript jquery html spring-boot thymeleaf