Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make increment for boostrap area-controls tag increment from thymeleaf

I need to make increment in area-controls boostrap taf with my list count. My code as under:

<th:block th:each="stateTitles, statesStatus: ${states}">
    <a data-toggle="collapse" id="stateCollapsed" class="collapsed" data-parent="#accordion" th:href="'#collapse' + ${statesStatus.index + 1}" 
        aria-expanded="true" aria-controls="'collapse' + ${statesStatus.index + 1}">
        <span id="state" th:text="${stateTitles}" /> 
        <span class="glyphicon glyphicon-menu-down"></span>
        <span class="glyphicon glyphicon-menu-up"></span>
    </a>
</th:block>

Increment is not working for area-controls tag. Thanks in advance.

like image 827
Waqas Baig Avatar asked Mar 16 '23 13:03

Waqas Baig


1 Answers

You need to use th:attr in order to inject values using Thymeleaf, check documentation here.

So change the code to:

<a data-toggle="collapse" id="stateCollapsed" class="collapsed" data-parent="#accordion" th:href="'#collapse' + ${statesStatus.index + 1}" 
        aria-expanded="true" th:attr="aria-controls='collapse' + ${statesStatus.index + 1}">
like image 64
Leandro Carracedo Avatar answered Mar 19 '23 21:03

Leandro Carracedo