Among the buttons in my gridview, there are options to trigger a bootstrap modal, each with different contents:
return Html::a('<i class="fa"></i> ', $key, [
'title' => 'View details of this agenda',
'data-bs-toggle' => 'modal',
'data-bs-target' => '#exampleModal',
'class' => 'modal-link',
]);
return Html::a('<i class="fab text-danger fa-readme"></i> ', ['report/' . $model->agenda_id], [
'title' => 'Report for agenda pending approval',
'data-bs-toggle' => 'modal',
'data-bs-target' => '#exampleModal',
'class' => 'modal-link',
]);
return Html::a('<i class="fab text-success fa-readme"></i> ', ['report/' . $model->agenda_id], [
'title' => 'View report for this agenda',
'data-bs-toggle' => 'modal',
'data-bs-target' => '#exampleModal',
'class' => 'modal-link',
]);
Below is the JavaScript function used to trigger the modal:
$(function () {
$('.modal-link').on('click', function (e) {
e.preventDefault();
$('#exampleModal').modal('show').find('#modalContent').load($(this).attr('href'));
});
});
Upon initial click, the correct content (href) is displayed. However, subsequent clicks show the content from the first click. How can I reset the content so that each click displays the accurate href content?
Update
Here are the JS libraries incorporated in my yii2 application:
'https://code.jquery.com/jquery-3.7.1.min.js',
'https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0c6f637e694c3e223d3d223a">[email protected]</a>/dist/umd/popper.min.js',
'library/restaurantly/assets/vendor/aos/aos.js',
'https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a0c2cfcfd4d3d4d2c1d0e0958e938e908dc1ccd0c8c191">[email protected]</a>/dist/js/bootstrap.min.js',
'library/restaurantly/assets/vendor/glightbox/js/glightbox.min.js',
'library/restaurantly/assets/vendor/swiper/swiper-bundle.min.js',
'library/restaurantly/assets/js/main.js',
'https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js',
Attempts to resolve the issue by removing these libraries individually resulted in the disappearance of the entire page.