Sweet alert for delete confirm in Codeigniter

Run Settings
LanguagePHP
Language Version
Run Command
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?> <!DOCTYPE html> <html> <!-- Head Start --> <head> <?php $this->load->view("_inc/head.php") ?> <link href="assets/plugins/bootstrap-sweetalert/sweet-alert.css" rel="stylesheet" type="text/css" /> <!--datatable css--> <link href="assets/plugins/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/buttons.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/fixedHeader.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/responsive.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/scroller.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/dataTables.colVis.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="assets/plugins/datatables/fixedColumns.dataTables.min.css" rel="stylesheet" type="text/css" /> </head> <!-- Head End --> <body class="fixed-left"> <!-- Begin page --> <div id="wrapper"> <!-- Top Bar Start --> <?php $this->load->view("_inc/topbar.php") ?> <!-- Top Bar End --> <!-- ========== Left Sidebar Start ========== --> <?php $this->load->view("_inc/leftsidebar.php") ?> <!-- Left Sidebar End --> <!-- ============================================================== --> <!-- Start right Content here --> <!-- ============================================================== --> <div class="content-page"> <!-- Start content --> <div class="content"> <div class="container"> <?php if ($this->session->flashdata('success')): ?> <div class="alert alert-success" role="alert"> <?php echo $this->session->flashdata('success'); ?> </div> <?php endif; ?> <!-- Page-Title --> <div class="row"> <div class="col-sm-12"> <div class="btn-group pull-right m-t-15"> <a href="<?php echo site_url('buku_tamu/add') ?>" class="btn btn-default dropdown-toggle waves-effect waves-light">Tambah</a> </div> <h4 class="page-title">Buku Tamu</h4> <p class="text-muted page-title-alt">Transaksi / Buku Tamu</p> </div> </div> <div class="row"> <div class="col-sm-12"> <div class="card-box table-responsive"> <h4 class="m-t-0 header-title"><b>Daftar Buku Tamu</b></h4> <br> <table id="datatable" class="table table-striped table-bordered"> <thead> <tr> <th>Tanggal</th> <th>Nama Lengkap</th> <th>Alamat</th> <th>Keperluan</th> <th>Bertemu</th> <th>Keterangan</th> <th></th> </tr> </thead> <tbody> <?php foreach ($bk_tamu as $x): ?> <tr id="<?php echo $x->buku_tamu_id; ?>"> <td><?php echo $x->tanggal ?></td> <td><?php echo $x->nama_lengkap ?></td> <td><?php echo $x->alamat ?></td> <td><?php echo $x->tujuan_kedatangan ?></td> <td><?php echo $x->bertemu ?></td> <td><?php echo $x->keterangan ?></td> <td> <a href="<?php echo site_url('buku_tamu/edit/'.$x->buku_tamu_id) ?>" class="btn btn-default waves-effect waves-light btn-sm"><i class="fa fa-edit"></i></a> - <button class="btn btn-danger waves-effect waves-light btn-sm hapus" ><i class="fa fa-trash"></i></button> </td> </tr> <?php endforeach ?> </tbody> </table> </div> </div> </div> </div> <!-- container --> </div> <!-- content --> <!-- Right Sidebar --> <?php $this->load->view("_inc/footer.php") ?> <!-- /Right-bar --> </div> <!-- ============================================================== --> <!-- End Right content here --> <!-- ============================================================== --> <!-- Right Sidebar --> <?php $this->load->view("_inc/rightsidebar.php") ?> <!-- /Right-bar --> </div> <!-- END wrapper --> <script> var resizefunc = []; </script> <!-- jQuery --> <?php $this->load->view("_inc/jquery.php") ?> <!-- Sweet-Alert --> <script src="<?php echo base_url('assets/plugins/bootstrap-sweetalert/sweet-alert.min.js') ?>"></script> <!-- Jquery Datatables --> <script src="<?php echo base_url('assets/plugins/datatables/jquery.dataTables.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.bootstrap.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.buttons.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/buttons.bootstrap.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/jszip.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/pdfmake.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/vfs_fonts.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/buttons.html5.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/buttons.print.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.fixedHeader.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.keyTable.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.responsive.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/responsive.bootstrap.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.scroller.min.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.colVis.js') ?>"></script> <script src="<?php echo base_url('assets/plugins/datatables/dataTables.fixedColumns.min.js') ?>"></script> <script type="text/javascript"> $(document).ready(function () { $('#datatable').dataTable(); $('.hapus').click(function () { var id = $(this).parents("tr").attr("id"); swal({ title: "Apakah Anda yakin?", text: "Data yang dihapus tidak dapat dikembalikan", type: "warning", showCancelButton: true, cancelButtonClass: 'btn-white btn-md waves-effect', confirmButtonClass: 'btn-danger btn-md waves-effect waves-light', confirmButtonText: 'Hapus' }, function(isConfirm) { if (isConfirm) { $.ajax({ url: '<?php echo site_url('buku_tamu/delete/') ?>'+id, type: 'DELETE', error: function() { alert('Something is wrong'); }, success: function(data) { $("#"+id).remove(); swal("Terhapus!", "Data berhasil dihapus.", "success"); } }); } else { swal("Cancelled", "Your imaginary file is safe :)", "error"); } }); }); }); </script> </body> </html>
Editor Settings
Theme
Key bindings
Full width
Lines