I am display a list of users using Twig:
{% for user in user.users %}
<div class="row user" data-id="{{ user.id }}">
<div class="col">{{ user.firstname }} {{ user.lastname }}</div>
<div class="col">{{ user.email }}</div>
<div class="col">{{ user.lastLogin|date("F j, Y \\a\\t g:i a") }}</div>
</div>
{% endfor %}
When the user clicks on this row, I would like a modal dialog to open with additional details about this specific user.
I have considered simply including the modal within the for loop. However, if the list contains several hundred users, I do not want to render all of this additional data on every page load.
My thought was to do something like this:
$('body').on('click', '.user', function() {
$('#user').modal();
});
But I am not sure how to dynamically render only the clicked user's data in the modal via twig:
<div class="modal fade" id="user" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
{{ user.firstname }} //additonal data for a given user
</div>
</div>
</div>
