I am facing an issue with a series of divs generated from data, each containing an arrow that should toggle an expandable section. Strangely, only the first div is functioning properly: toggling the arrow icon and revealing the content upon click.
When the template renders multiple times based on backend data instances, the remaining divs display the arrow but do not respond to clicks. I suspect this means the jQuery script is not executing as intended. Could it be that the syntax in my jQuery code restricts functionality to only the initially rendered div?
jQuery:
$('.remove-text').click(function () {
$(this).closest('.card').toggleClass('collapsed');
if ($('.arrow-change').text() == 'expand_more') {
$('.arrow-change').text('expand_less');
} else {
$('.arrow-change').text('expand_more');
}
});
HTML:
<template name="printJob">
<div class="row m-b-0">
<div class="col s12 m12 l12">
<div class="card hoverable collapsed">
<div class="card-content card-content-width">
</div>
<div class="col s3 m3 l1">
<div class="display-inline remove-text" href="#">
<i class="material-icons medium-3-rem arrow-change">expand_more</i>
</div>
</div>
</div>
<div class="content dm-gray light">
<div class="col s1 m1 l1 more-horiz-col">
<i class="material-icons medium-3-rem more-horiz-job dis-inline">more_horiz</i>
</div>
<div class="col s4 m4 l4 view-edit-col">
<div class="label dis-inline view-edit">View/Edit</div>
</div>
<div class="col s4 m4 l4">
<div class="dis-inline right delete-div">DELETE<i class="material-icons medium-3-rem dis-inline">delete</i></div>
</div>
</div>
</div>
</div>
</div>
</template>