チェックイン削除モーダルのセットアップは共通処理に吸収

This commit is contained in:
shibafu 2019-03-05 01:22:49 +09:00
parent 37eaefc016
commit 0ceb0fcf21
4 changed files with 17 additions and 33 deletions

View File

@ -28,4 +28,5 @@ $(() => {
}
$('.link-card').linkCard();
$('#deleteCheckinModal').deleteCheckinModal();
});

View File

@ -55,4 +55,20 @@
});
};
$.fn.deleteCheckinModal = function () {
return this.each(function () {
$(this).on('show.bs.modal', function (event) {
var target = $(event.relatedTarget);
var modal = $(this);
modal.find('.modal-body .date-label').text(target.data('date'));
modal.data('id', target.data('id'));
}).find('.btn-danger').on('click', function (event) {
var modal = $('#deleteCheckinModal');
var form = modal.find('form');
form.attr('action', form.attr('action').replace('@', modal.data('id')));
form.submit();
})
});
};
})(jQuery);

View File

@ -89,20 +89,3 @@
@endslot
@endcomponent
@endsection
@push('script')
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/holderjs@2.9.4/holder.min.js"></script>
<script>
$('#deleteCheckinModal').on('show.bs.modal', function (event) {
var target = $(event.relatedTarget);
var modal = $(this);
modal.find('.modal-body .date-label').text(target.data('date'));
modal.data('id', target.data('id'));
}).find('.btn-danger').on('click', function (event) {
var modal = $('#deleteCheckinModal');
var form = modal.find('form');
form.attr('action', form.attr('action').replace('@', modal.data('id')));
form.submit();
});
</script>
@endpush

View File

@ -98,19 +98,3 @@
@endslot
@endcomponent
@endsection
@push('script')
<script>
$('#deleteCheckinModal').on('show.bs.modal', function (event) {
var target = $(event.relatedTarget);
var modal = $(this);
modal.find('.modal-body .date-label').text(target.data('date'));
modal.data('id', target.data('id'));
}).find('.btn-danger').on('click', function (event) {
var modal = $('#deleteCheckinModal');
var form = modal.find('form');
form.attr('action', form.attr('action').replace('@', modal.data('id')));
form.submit();
});
</script>
@endpush