diff --git a/app/javascript/controllers/event_duplication_controller.js b/app/javascript/controllers/event_duplication_controller.js index 7b9650f..7e4ae76 100644 --- a/app/javascript/controllers/event_duplication_controller.js +++ b/app/javascript/controllers/event_duplication_controller.js @@ -1,27 +1,30 @@ import { Controller } from "@hotwired/stimulus" export default class extends Controller { - static targets = ["modal", "cloneTicketTypes"] + static targets = ["cloneTicketTypes"] static values = { duplicateUrl: String } connect() { + // Get modal element from the document + this.modalElement = document.querySelector('[data-event-duplication-target="modal"]') + // Close modal when clicking outside - this.modalTarget.addEventListener('click', (event) => { - if (event.target === this.modalTarget) { + this.modalElement.addEventListener('click', (event) => { + if (event.target === this.modalElement) { this.close() } }) } open() { - this.modalTarget.classList.remove('hidden') + this.modalElement.classList.remove('hidden') document.body.classList.add('overflow-hidden') } close() { - this.modalTarget.classList.add('hidden') + this.modalElement.classList.add('hidden') document.body.classList.remove('overflow-hidden') } diff --git a/app/views/promoter/events/show.html.erb b/app/views/promoter/events/show.html.erb index 42b7058..e7bbe07 100644 --- a/app/views/promoter/events/show.html.erb +++ b/app/views/promoter/events/show.html.erb @@ -1,52 +1,6 @@ <% content_for(:title, @event.name) %>