削除確認モーダルのsubmit処理を変更

This commit is contained in:
shibafu 2020-08-07 22:35:49 +09:00
parent 2f928a29e1
commit 969bc79cbc
2 changed files with 20 additions and 17 deletions

View File

@ -16,14 +16,17 @@ $('.copy-to-clipboard').on('shown.bs.popover', function () {
setTimeout(() => $(this).popover('hide'), 3000); setTimeout(() => $(this).popover('hide'), 3000);
}); });
const $deleteModal = $('#deleteIncomingWebhookModal'); const deleteModal = document.getElementById('deleteIncomingWebhookModal');
$deleteModal.find('.btn-danger').on('click', function () { if (deleteModal) {
const $form = $deleteModal.find('form'); let id: any = null;
$form.attr('action', $form.attr('action')?.replace('@', $deleteModal.data('id')) || null); deleteModal.querySelector('form')?.addEventListener('submit', function () {
$form.submit(); this.action = this.action.replace('@', id);
}); });
$('[data-target="#deleteIncomingWebhookModal"]').on('click', function (event) { document.querySelectorAll<HTMLElement>('[data-target="#deleteIncomingWebhookModal"]').forEach((el) => {
event.preventDefault(); el.addEventListener('click', function (e) {
$deleteModal.data('id', $(this).data('id')); e.preventDefault();
$deleteModal.modal('show', this); id = this.dataset.id;
$(deleteModal).modal('show', this);
}); });
});
}

View File

@ -54,13 +54,13 @@
削除確認 削除確認
@endslot @endslot
Webhookを削除してもよろしいですか Webhookを削除してもよろしいですか
@slot('footer')
<form action="{{ route('setting.webhooks.destroy', ['webhook' => '@']) }}" method="post"> <form action="{{ route('setting.webhooks.destroy', ['webhook' => '@']) }}" method="post">
{{ csrf_field() }} {{ csrf_field() }}
{{ method_field('DELETE') }} {{ method_field('DELETE') }}
</form>
@slot('footer')
<button type="button" class="btn btn-secondary" data-dismiss="modal">キャンセル</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">キャンセル</button>
<button type="button" class="btn btn-danger">削除</button> <button type="submit" class="btn btn-danger">削除</button>
</form>
@endslot @endslot
@endcomponent @endcomponent
@endsection @endsection