I use Boostrap 3.7 and Blade (Laravel 5.5).
I'm trying to display console.log('works')
when my boostrap modal opens but it didn't work.
HTML :
@foreach(...)
...
<div class="modal fade" id="reservationModal" tabindex="-1" role="dialog" aria-labelledby="reservationModal" aria-hidden="true">
<div class="modal-dialog">
...
</div>
</div>
@endforeach
JS :
$('#reservationModal').on('shown.bs.modal', function (e) {
console.log('works');
});
I followed this doc : https://getbootstrap.com/docs/3.3/javascript/#modals
And I already read that : Calling a function on bootstrap modal open
Thank's for help !
EDIT 1:
I solved the problem with this code :
$(document).on('show.bs.modal', '#reservationModal', function (e) {
console.log('works');
});
But how to differenciate modals (because they are into foreach
loop)?
Something like :
$(document).on('show.bs.modal', '#reservationModal-specificId', function (e) {
console.log('works');
});