StocksNew/public/assets/js/custom.js
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

68 lines
1.6 KiB
JavaScript

$('body').on('click', '.remove-item-btn', function (e) {
e.preventDefault();
let url = $(this).data('link');
let id = $(this).data('id');
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: url,
type: 'DELETE',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
id: id
},
success: function (response) {
location.reload();
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
}
});
}
});
});
//initialize ckeditor
document.querySelectorAll('.ckeditor-classic').forEach(editor => {
ClassicEditor
.create(editor)
.catch(error => {
console.error(error);
});
});
//initialize select2
$('.dropify').dropify();
//initialize select2
$('.select2').select2();
$(".flatpickr-date").flatpickr({
enableTime: false,
dateFormat: "Y-m-d",
minDate: "today",
altInput: true,
altFormat: "Y-m-d",
// defaultDate: "today",
});
$(".flatpickr-time").flatpickr({
enableTime: true,
noCalendar: false,
dateFormat: "H:i",
time_24hr: false,
});