Variable expression into javascript without using th:inline

前端 未结 6 972
广开言路
广开言路 2020-12-10 04:41

I searched first but I found confusing answers since I\'m new to Thymeleaf and amateurish at best at javascript.

I just want to know how to pass variable expressions

6条回答
  •  难免孤独
    2020-12-10 05:17

    In Thymeleaf version 2.1, I have not been able to get the accepted answer to work. I did find some guidance from a Twitter post from Thymeleaf. Rather than using th:onclick, you use th:attr and specify the onclick attribute therein.

    th:attr="onclick='javascript:getContactId(\'' + ${contact.id} + '\');'"
    

提交回复
热议问题