我在動態填充表中使用List.js時遇到了問題。我的項目是在春天mvc與百里香作爲模板引擎。當我將List.js與現有的或靜態表一起使用時,它工作正常,但是當我將它用於動態填充的表時,它不起作用。在動態填充表中使用List.js百里香彈簧mvc
以下是事情我已經做了:這裏的值從春天來臨控制器
notification.html
<div id="box-body pad table-responsive">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">Sort by ID</button>
<table class="table table-bordered text-center">
<thead>
<tr>
<th>ID</th>
<th>DUMP FILE</th>
<th>LOG</th>
<th>DATE</th>
<th>MESSAGE</th>
</tr>
</thead>
<tbody class = "list">
<tr th:each="searchNotification : ${backupSearchNotification}">
<td class = "name" th:text="${searchNotification.id}"></td>
<td class = "dumpfile" th:text="${searchNotification.dumpfile}"></td>
<td class = "log" th:text="${searchNotification.log}"></td>
<td class = "endtime" th:text="${searchNotification.endtime}"></td>
<td class = "status" th:if="${searchNotification.status == 0}"><span class="label label-default" style="width: 50px;"><b>Created</b></span></td>
<td class = "status" th:if="${searchNotification.status == 1}"><span class="label label-primary"><b>Running</b></span></td>
<td class = "status" th:if="${searchNotification.status == 2}"><span class="label label-success"><b>Completed with
Success</b></span></td>
<td class = "status" th:if="${searchNotification.status == 3}"><span class="label label-info" style="width: 50px;"><b>Completed
with MDHASH</b></span></td>
<td class = "status" th:if="${searchNotification.status == 100}"><span class="label label-danger" style="width: 50px;"><b>Stopped
with Error</b></span></td>
</tr>
</tbody>
</table>
</div>
<div layout:fragment="script">
<script>
var options = {
valueNames: [ 'name' ]
};
var userList = new List('box-body pad table-responsive', options);
</script>
</div>
,它是正確的顯示它。但搜索不起作用。同時,如果我將動態表更改爲普通靜態表,如下所示:
<div id="box-body pad table-responsive">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">Sort by name</button>
<table class="table table-bordered text-center">
<thead>
<tr>
<th>Name</th>
<th>Year</th>
</tr>
</thead>
<tbody class = "list">
<tr>
<td class = "name">Jonny</td>
<td class = "born">1991</td>
</tr>
<tr>
<td class = "name">Harry</td>
<td class = "born">1992</td>
</tr>
</tbody>
</table>
</div>
而且腳本是一樣的。然後List.js對這個靜態表格工作正常,該列表被過濾。
那麼請任何人都可以幫助我?我想過濾動態填充表中的搜索。
在此先感謝!
乾杯!
動態表生成HTML
靜態表生成HTML
我檢查了由thymeleaf提供的HTML和靜態內容,通過檢查瀏覽器中的元素,我發現沒有任何區別,即它們是相同的。再加上我然後在js腳本之前使用$(document).ready(),它仍然不起作用。 – anishroniyar
你能夠共享從Thymeleaf和靜態生成的HTML內容,所以我們可以檢討? – Aeseir
我已經在主題中添加了由thymeleaf生成的動態表格和來自inspect元素的靜態內容生成的快照。希望這會起作用。 – anishroniyar