【发布时间】:2019-03-27 00:14:38
【问题描述】:
我正在构建一个 Thymeleaf+SpringBoot 应用程序,我有一段时间使用 Thymeleaf foreach 循环,其中我在一个 div 中有一个模态 - 它重复几次,我想更新模态的索引和显示它的按钮我的模态将由特定按钮显示。我在更新索引时遇到问题,因为当我这样做时,我的按钮停止工作并且没有显示任何模式......
我检查过:
a)How can I do data-target="#userId" in thymeleaf
b)using data-* attribute with thymeleaf
但还是不行……
这里是部分代码: 循环:
<div th:each="myth : ${allMyths}">
这里是按钮(注释代码也不起作用...):
<button type="button" class="button" style="float: right; margin-right: 2%" data-toggle="modal"
data-th-target="'#'+${myth.getId()}">More...
<!--th:attr="data-target='#'+${myth.getId()}">More...-->
</button>
这里是模态的顶部:
<div data-th-id="${myth.getId()}" class="modal fade" role="dialog">
这里也 th:id 不起作用... 你知道为什么按钮和模式不能通过 ID 找到彼此吗?
提前感谢您的回答/建议!
彼得
【问题讨论】:
-
你能告诉我们你的错误日志吗?这可以帮助我们。
-
嗨阿兰!实际上,当我按下按钮时我没有出现任何错误 - 它只是不起作用:)它仅在我回到标准设置时才显示模式,例如: data-target="#someId" 和在模态 id="someId"
-
当涉及到我的页面时,它只是 " thymeleaf.org">" 并且在依赖项中我有 "
org.thymeleaf thymeleaf-spring3 3.0.10.RELEASE " 和 "org.springframework.boot spring-引导启动器-thymeleaf " -
其实我是用另一种方式解决的!我在java中找到了一个脚本:“ " 我只是在 modal 和 button 中声明 th:id 并且它可以工作:)
标签: spring-boot bootstrap-modal thymeleaf