kopia lustrzana https://github.com/magicbug/Cloudlog
Added AJAX-delete of mode as well.
rodzic
529c81575c
commit
337caa1424
|
@ -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() {
|
||||
|
|
|
@ -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= "<?php echo base_url();?>";
|
||||
$.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
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<a href="<?php echo site_url('mode/edit')."/".$row->id; ?>" class="btn btn-info btn-sm"><i class="fas fa-edit-alt"></i> Edit</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo site_url('mode/delete')."/".$row->id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want delete mode <?php echo $row->mode; ?> ');"><i class="fas fa-trash-alt"></i> Delete</a>
|
||||
<a href="javascript:deleteMode('<?php echo $row->id; ?>', '<?php echo $row->mode; ?>');" class="btn btn-danger btn-sm" ><i class="fas fa-trash-alt"></i> Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue