【发布时间】:2018-08-03 23:27:55
【问题描述】:
这是按下按钮删除时调用的函数。确认删除后,我想隐藏删除tr:
function delete_confirmation(id) {
var $tr = $(this).closest('tr');
swal({
title: "Are you sure?",
text: "To delete this patient!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
$.ajax({
url: localStorage.getItem("base_url") + '' + 'index.php/Patient_ws/delete/',
timeout: 4000,
type: "POST",
data: ({id: id}),
}).done(function () {
$tr.remove();
})
.fail(function () {
swal({
title: ' erreur in server, try later...',
type: 'warning'
})
})
} else {
swal("Patient not deleted");
}
});
}
HTML 标记:
<a href="#" class="btn btn-danger btn-xs" onclick="delete_confirmation(<?php echo $patient->id_personne;?>)">
<i class="fa fa-trash-o"></i> Delete </a>
我想隐藏 tr - 请帮忙。
【问题讨论】:
-
请添加一些细节以澄清“不起作用”。发生什么了?没有?不是你想要的东西?错误?
-
删除请求工作。但确认后
没有被删除 我明白了。所以<a>和onclick="delete_confirmation()"在你想被删除的<tr>里面,对吧?只要确保是的,包含我按下的按钮删除的 tr 将在确认删除操作后被删除当我写 console.log(this): messege:Window {postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, frames: Window, …}
标签: php jquery ajax codeigniter