fixed issue where calling modal was only appeared for the first contact in list

This commit is contained in:
Beatrice Olivera
2018-09-01 20:23:53 +01:00
parent 1b7a58e4bf
commit 6a1992a29f
2 changed files with 13 additions and 10 deletions

View File

@@ -1,12 +1,15 @@
const triggerModalEvent = () => {
const btn = document.getElementById("modalTrigger");
const modal = document.getElementById("myModal");
if (btn) {
btn.addEventListener('click', function(event) {
$('#myModal').modal('show');
});
}
const buttons = document.querySelectorAll(".modalTrigger");
buttons.forEach(btn => {
if (btn) {
btn.addEventListener('click', function(event) {
const btnId = btn.getAttribute('data-user-id')
$("#myModal"+`${btnId}`).modal('show');
});
}
})
}
export { triggerModalEvent }