Spring Thymeleaf 折叠表 :id

标签 spring twitter-bootstrap-3 thymeleaf

我试图使每个表条目都有一个可以展开/折叠的隐藏行,因此我尝试使用迭代来分配 th:id 但这似乎不起作用。所有内容均已生成,但按下按钮时隐藏行不会展开。

知道为什么吗?或者还有其他解决方案/解决方法吗?

<tbody th:each="topic, iterStat : ${topics}">
    <tr>
        <td>
            <button data-toggle="collapse" data-th-target="'#demo' + ${iterStat.count}"> +</button>
        </td>
        <td th:text="${topic.getId()}"></td>
        <td th:text="${topic.getName()}"></td>
        <td th:text="${topic.getDescription()}"></td>
    </tr>
    <tr>
        <td colspan="6" class="hiddenRow">
            <div class="accordian-body collapse" th:id="'demo' + ${iterStat.count}"> Lorem ipsum</div>
        </td>
    </tr>
</tbody>

最佳答案

这个 data-th-target="'#demo' + ${iterStat.count}" 将不起作用。 Thymeleaf 中的任何自定义属性都需要定义为:th:attr="data-th-target=|#demo${iterStat.count}|"

更新:

属性应该是data-target而不是data-th-target

关于Spring Thymeleaf 折叠表 :id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47126668/

相关文章:

java - Spring MVC xml配置

java - 我如何在 spring data hibernate 的关系表中使用 findBy

java - 如何对 ElementCollection 和 CollectionTable 使用 CriteriaQuery

html - twitter bootstrap 应用类的良好实践

java - Thymeleaf 显示具有动态列数的表格

spring - 使用 Thymeleaf Security 为匿名用户显示特定内容

java - Autowiring 字段仍然为空

java - 使用Spring data JPA,如何为过滤器表单创建动态查询

javascript - 在 Bootstrap 进度条上方显示范围 slider (在导航栏中)

javascript - Bootstrap 表 - 多排序扩展中的 sortPriority 不起作用