From 969bc79cbc0e2b6f4e4eceaa5bc31b65f1fdbaea Mon Sep 17 00:00:00 2001 From: shibafu Date: Fri, 7 Aug 2020 22:35:49 +0900 Subject: [PATCH] =?UTF-8?q?=E5=89=8A=E9=99=A4=E7=A2=BA=E8=AA=8D=E3=83=A2?= =?UTF-8?q?=E3=83=BC=E3=83=80=E3=83=AB=E3=81=AEsubmit=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/setting/webhooks.ts | 25 ++++++++++++---------- resources/views/setting/webhooks.blade.php | 12 +++++------ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/resources/assets/js/setting/webhooks.ts b/resources/assets/js/setting/webhooks.ts index 42933d2..748e6bb 100644 --- a/resources/assets/js/setting/webhooks.ts +++ b/resources/assets/js/setting/webhooks.ts @@ -16,14 +16,17 @@ $('.copy-to-clipboard').on('shown.bs.popover', function () { setTimeout(() => $(this).popover('hide'), 3000); }); -const $deleteModal = $('#deleteIncomingWebhookModal'); -$deleteModal.find('.btn-danger').on('click', function () { - const $form = $deleteModal.find('form'); - $form.attr('action', $form.attr('action')?.replace('@', $deleteModal.data('id')) || null); - $form.submit(); -}); -$('[data-target="#deleteIncomingWebhookModal"]').on('click', function (event) { - event.preventDefault(); - $deleteModal.data('id', $(this).data('id')); - $deleteModal.modal('show', this); -}); +const deleteModal = document.getElementById('deleteIncomingWebhookModal'); +if (deleteModal) { + let id: any = null; + deleteModal.querySelector('form')?.addEventListener('submit', function () { + this.action = this.action.replace('@', id); + }); + document.querySelectorAll('[data-target="#deleteIncomingWebhookModal"]').forEach((el) => { + el.addEventListener('click', function (e) { + e.preventDefault(); + id = this.dataset.id; + $(deleteModal).modal('show', this); + }); + }); +} diff --git a/resources/views/setting/webhooks.blade.php b/resources/views/setting/webhooks.blade.php index be18ce5..d9f4d08 100644 --- a/resources/views/setting/webhooks.blade.php +++ b/resources/views/setting/webhooks.blade.php @@ -54,13 +54,13 @@ 削除確認 @endslot Webhookを削除してもよろしいですか? -
- {{ csrf_field() }} - {{ method_field('DELETE') }} -
@slot('footer') - - +
+ {{ csrf_field() }} + {{ method_field('DELETE') }} + + +
@endslot @endcomponent @endsection