diff --git a/app/javascript/components/modal.js b/app/javascript/components/modal.js index a35d32a..f4cdcf0 100644 --- a/app/javascript/components/modal.js +++ b/app/javascript/components/modal.js @@ -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 } diff --git a/app/views/pages/_contact.html.erb b/app/views/pages/_contact.html.erb index 7b06c6c..92f1689 100644 --- a/app/views/pages/_contact.html.erb +++ b/app/views/pages/_contact.html.erb @@ -16,19 +16,19 @@
- <%= link_to establish_call_path(contact.id), remote: true, id: "modalTrigger" do %> + <%= link_to establish_call_path(contact.id), remote: true, class: "modalTrigger", data: {'user-id': contact.id } do %> <% end %>
-