Sending LinkedList to JS Function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending LinkedList to JS Function

Matthias
Hi,

how can I send a LinkedList to a Js Function with Thymeleaf?

Anything like that?:
Controller:
List<Position> mapPos = dab.getPositionWithDateRange(from, to, d.getId());
                m.addAttribute("PosDaten", mapPos);

HTML:
th:onclick="'javascript:drawLines(\'' + ${PosDaten} +'\')'"

Thanks for your help
Reply | Threaded
Open this post in threaded view
|

Re: Sending LinkedList to JS Function

Zemi
Administrator
Hello,

it depends on how you need it inside Javascript.

If you assign it to a variable using Javascript inlining it will be serialized as JSON.

  <script th:inline="javascript">
     var postdaten = /*[[${PosDaten}]]*/ 'test';
  </script>

Kind regards,
  Zemi