Currently, I am utilizing Bootstrap v5.1.3 along with vanilla JavaScript, but it appears that I have misunderstood how to set up modal event listeners. Below is my current setup for two modals:
var firstModal = new bootstrap.Modal(document.getElementById("firstModal"));
var firstModalEL = document.getElementById('firstModal');
firstModalEL.addEventListener('show.bs.modal', function (event) {
console.log("firstModal");
});
var secondModal = new bootstrap.Modal(document.getElementById("secondModal"));
var secondModalEL = document.getElementById('secondModal');
secondModalEL.addEventListener('show.bs.modal', function (event) {
console.log("secondModal");
});
However, when I trigger the display of the second modal using
secondModal.show();
the event listener for the first modal ends up executing. It seems like something is amiss in my approach. Can anyone pinpoint where I might be making a mistake?