class TicketModal { constructor() { this.$modal = $("#ticket-modal"); this.modal = bootstrap.Modal.getInstance(this.$modal.get(0)); this.$modal.on("show.bs.modal", event => this.onShow(event)); this.$modal.on("shown.bs.modal", () => this.onShown()); this.$modal.on("hidden.bs.modal", () => this.onHidden()); this.$title = this.$modal.find(".modal-title"); this.$form = this.$modal.find("form"); this.$form.on("submit", event => this.onSubmit(event)); this.$subjectField = this.$form.find("[name=subject]"); this.$locationDropdown = this.$form.find("[name=location_id]"); } // Modal lifecycle onShow(event) { const $element = $(event.relatedTarget); const data = $element.data(); } onShown() { this.$subjectField.trigger("focus"); fetch("/locations/get-options").then(body => { return body.json() }).then(response => { const $options = response.options.map(option => { const $option = $(`