Search code examples
javascriptjqueryhtmlthymeleaf

Thymeleaf: Error parsing a Javascript expression


I have a Thymeleaf template with this piece of code

<a href="#" th:onclick="'performAjaxCall('@{/mymenupricesummary/pricealarm/1/{id}(id=${menuPriceSummary.menu.id})}');'">

But when I start the app I got this error:

Could not parse as expression: "javascript: ...

Solution

  • Yes, you need to format this correctly. This works for me:

    <a href="#" th:onclick="'performAjaxCall(\'' + @{/mymenupricesummary/pricealarm/1/{id}(id=${menuPriceSummary.menu.id})} + '\');'">