From 337caa14249deea4a11321740f3dc5f63bd5bae6 Mon Sep 17 00:00:00 2001 From: Andreas Date: Tue, 13 Oct 2020 12:38:44 +0200 Subject: [PATCH] Added AJAX-delete of mode as well. --- application/controllers/Mode.php | 5 ++-- application/views/interface_assets/footer.php | 25 +++++++++++++++++++ application/views/mode/index.php | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/application/controllers/Mode.php b/application/controllers/Mode.php index 3699f2d8..258e1a22 100644 --- a/application/controllers/Mode.php +++ b/application/controllers/Mode.php @@ -80,11 +80,10 @@ class Mode extends CI_Controller { } } - public function delete($id) { + public function delete() { + $id = $this->input->post('id'); $this->load->model('modes'); $this->modes->delete($id); - - redirect('mode'); } public function activate() { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index de054d5c..755dbcfa 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -1888,6 +1888,31 @@ $(document).ready(function(){ } }); } + + function deleteMode(id, mode) { + BootstrapDialog.confirm({ + title: 'DANGER', + message: 'Warning! Are you sure you want to delete the following mode: ' + mode + '?' , + type: BootstrapDialog.TYPE_DANGER, + closable: true, + draggable: true, + btnOKClass: 'btn-danger', + callback: function(result) { + if(result) { + var baseURL= ""; + $.ajax({ + url: baseURL + 'index.php/mode/delete', + type: 'post', + data: {'id': id + }, + success: function(data) { + $(".mode_" + id).parent("tr:first").remove(); // removes mode from table + } + }); + } + } + }); + } diff --git a/application/views/mode/index.php b/application/views/mode/index.php index e7477ae6..0b6c27ea 100644 --- a/application/views/mode/index.php +++ b/application/views/mode/index.php @@ -46,7 +46,7 @@ id; ?>" class="btn btn-info btn-sm"> Edit - id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete mode mode; ?> ');"> Delete + Delete