-1

im here this time to ask a question about Thymeleaf, i would like to understand if i can use th:if to change the value of a boolean.

I will explain here, i have a program for recipes, i have two booleans, one for vegan and one for vegetarian.

What i want to do is, when i click on vegan and it becomes true, i want to use th:if to auotmaticaly change Vegetarian to TRUE.

Is it possibile ??

I started wth this, but i do not know how to end it:

<span th:if="${isVegan == 'True'}"> </span>

1 Answers1

1

The syntax for evaluating that expression would be:

<span th:if="${isVegan}"></span>

However, Thymeleaf is a server side templating engine -- if you want to see the section appear/disappear you would have to submit the page to the server and change the value of isVegan on the return trip. If you want to it happen dynamically on the page without a server trip you will need to use something like JavaScript.

Metroids
  • 18,999
  • 4
  • 41
  • 52