FE/html
[Thymeleaf] th:attr로 속성에 값 할당하기
잔망루피
2022. 6. 3. 22:02
😶🌫️ 문제점
<button type="button" onclick=openModal('${comment.id}', '${comment.user_name}', '${comment.comment}' ) class="bi bi-pencil"></button>
이렇게 하면 모달창은 뜨지만 '${comment.id}' 형태로 값이 그대로 들어간다.
✨ 해결
<button type="button" th:attr="onclick=|openModal('${comment.id}', '${comment.user_name}', '${comment.comment}' )|" class="bi bi-pencil"></button>
th:attr을 사용했다.
참고 👇
https://jjeong.tistory.com/1466
[Thymeleaf] <a> onclick 및 modal 에 변수 전달 하기.
알면 쉽고 모르면 고생하는... 상세정보 상세정보 data-toggle="modal" href="#deleteThingCertificateModal" th:data-certid="${thingCertificate.certificateId}" th:data-certname="${thingCertificate.certifi..
jjeong.tistory.com
반응형