title: Thymeleaf modal data-target and id update in the loop
body: <p>I'm building a Thymeleaf+SpringBoot application and I have a moment with Thymeleaf foreach loop where I have a modal inside one div - it repeats few times and I want to update index of a modal and the button which shows it so that my modal will be shown by particular button. I have an issue with updating index because when I do it then my button stop to work and no modal is shown...</p>
  
  <p>I checked:</p>
  
  <p>a) <a href="https://stackoverflow.com/questions/26397240/how-can-i-do-data-target-userid-in-thymeleaf">How can I do data-target=&quot;#userId&quot; in thymeleaf</a></p>
  
  <p>b) <a href="https://stackoverflow.com/questions/24411826/using-data-attribute-with-thymeleaf#24432675">using data-* attribute with thymeleaf</a></p>
  
  <p>but still it does not work...</p>
  
  <p>here is part of the code:
  The loop:</p>
  
  <pre><code>&lt;div th:each="myth : ${allMyths}"&gt;
  </code></pre>
  
  <p>here is button (commented code also does not work...):</p>
  
  <pre><code>&lt;button type="button" class="button" style="float: right; margin-right: 2%" data-toggle="modal"
                          data-th-target="'#'+${myth.getId()}"&gt;More...
                          &lt;!--th:attr="data-target='#'+${myth.getId()}"&gt;More...--&gt;
                  &lt;/button&gt;
  </code></pre>
  
  <p>and here is top of the modal:</p>
  
  <pre><code>&lt;div data-th-id="${myth.getId()}" class="modal fade" role="dialog"&gt;
  </code></pre>
  
  <p>here also th:id does not work...
  Do you have any idea why button and modal does not find each other by ID?</p>
  
  <p>Thanks in advance for your answers/suggestions!</p>
  
  <p>Piotr</p>