Skip to content

Instantly share code, notes, and snippets.

@mehmetsarr
Last active November 24, 2023 19:31
Show Gist options
  • Save mehmetsarr/25ccc9b25e1b6659f942764f14f7cfa5 to your computer and use it in GitHub Desktop.
Save mehmetsarr/25ccc9b25e1b6659f942764f14f7cfa5 to your computer and use it in GitHub Desktop.
CodeIgniter 4 I sweetalert2 Kullanımı
</head> dan önce
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.js"></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css"
id="theme-styles"
/>
yükleyin.
View dosyasına da aşağıdaki kodu ekleyiniz.
<a class="btn btn-danger btn-sm" onclick="confirmDelete('rowid')"><i class="fa fa-trash"></i></a>
<script>
function confirmDelete(rowid) {
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) {
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
).then(() => {
window.location.href = '<?= base_url('remove') ?>/<?= esc($crt['rowid']) ?>';
});
}
})
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment