Good,
I am trying to dynamically call the "id" in the tags with the "th: each", as follows.
<div th:each="alumno : ${alumnos}" class="row" th:id="'card_' + ${alumno.id}" style="display: none">
<div class="col s12 m10">
<div class="card black darken-1">
<div class="card-content lime-text text-darken-1">
<span class="card-title" th:text="${alumno.nombres} + ' ' + ${alumno.apellidos}"></span>
</div>
</div>
</div>
<script th:inline="javascript">
/*<![CDATA[*/
$('#show_[${alumno.id}]]').click(function () {
$('#card_[${alumno.id}]]').fadeToggle( "fast", "linear" );
});
/*]]>*/
</script>
</div>
the result I expect (in jQuery ), iterated, would be as follows:
<script th:inline="javascript">
/*<![CDATA[*/
$('#close_EclairLast').click(function () {
$('#card123').fadeToggle( "fast", "linear" );
});
$('#show_1').click(function () {
$('#card_1').fadeToggle( "fast", "linear" ); //aqui seria card_[1...n]
});
/*]]>*/
</script>
is there any way to concatenate the value of the object $ {pupil.id} in jquery so that it is dynamic ???
The id="show_n" also dynamically generated in a table ...
<table class="striped grey lighten-5">
<thead>
<tr>
<th>CI</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Telefono</th>
<th>Acciones</th>
</tr>
</thead>
<tbody>
<tr th:each="alumno : ${alumnos}">
<td th:text="${alumno.cedula}"></td>
<td th:text="${alumno.nombres}"></td>
<td th:text="${alumno.apellidos}"></td>
<td th:text="${alumno.telefono}">0971490111</td>
<td>
<a class="btn-floating light-blue darken-4" th:id="'show_' + ${alumno.id}"><i class="material-icons">remove_red_eye</i></a>
<a class="btn-floating light-green darken-4" th:id="'edit_' + ${alumno.id}"><i class="material-icons">mode_edit</i></a>
<a class="btn-floating red darken-4" th:id="'remove_' + ${alumno.id}"><i class="material-icons">delete</i></a>
</td>
</tr>
</tbody>
</table>
Greetings .-