0

From Springboot I create an attribute having a list as value:

attributes.addFlashAttribute("mylist", mylist);

On client-side a need to pass this list to a javascript function. I used:

<th scope="col">
       <i class="fas fa-plus" type="button" 
      th:onclick="|myfunction('staticValue', [[${mylist}]]);|">
      </i>
</th>
      

The result is that the th tag disappear from the table. The javascript works when I do not use the thymeleaf attribute. I'm using thymeleaf 3.0.15.

As suggested I'm also using with no success:

<i class="fas fa-plus" type="button" 
   th:data-materialTypeSetDes="${mylist}"
   onclick="function('staticValue', this.getAttribute('data-materialTypeSetDes'));"></i>
3
  • Does this answer your question? How to pass arguments to javascript function call when using onClick in Thymeleaf Commented Nov 13, 2022 at 19:39
  • No, I have updated the question, maybe I introduced another typo Commented Nov 13, 2022 at 19:55
  • 1
    Thank you for trying. In that case, we probably need a minimal reproducible example. The updated code you show in your question works for me (except I'm not using Font Awesome, which I do not think is relevant to your issue). At the very least, can you show what gets rendered? The data in the Java List should be shown - something like data-materialTypeSetDes="[foo, bar]". A MRE may make this clearer. Commented Nov 13, 2022 at 20:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.