Thymeleaf onclick send td value to javascript function
14,966
Solution 1
Above issue is resolved now, we need to use Thymeleaf specific syntax.
th:onclick="'getPropId(\'' + ${properties.id} + '\');'"
Now if its displying proper properties.id in javascript function.
function getPropId(inputID){
alert(inputID);
}
Solution 2
For passing multiple parameters, you can use the following:
th:onclick="'doSomething(\''+${val1}+ '\',\''+${val2}+'\',\''+${val3}+'\');'"
Solution 3
Cleaner with literal substitution ||:
th:onclick="|getPropId('${properties.id}');|"
Multiple case:
th:onclick="|getPropId('${var1}','${var2}');|"
Author by
Admin
Updated on July 09, 2022Comments
-
Admin almost 2 years
I am using "Thymeleaf", I want to send the value to javascript, I am new to this, I am trying below code:
onclick="getPropId('${properties.id}')"
and function
getPropId(inputID){alert(inputId);}
But I am not getting actual value.
-
rajadilipkolli almost 8 yearsHow to achieve if I have two parameters to be passed