Sử dụng code:
<script type="text/javascript">
//Delete event handler.
$("body").on("click", "#WebGrid TBODY .Delete", function () {
if (confirm("Do you want to delete this row?")) {
var row = $(this).closest("tr");
var customerId = row.find(".label").html();
$.ajax({
type: "POST",
url: "/Home/DeleteCustomer",
data: '{customerId: ' + customerId + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if ($("#WebGrid TBODY tr").length == 1) {
row.find(".label").html("");
row.find(".text").val("");
row.find(".link").hide();
} else {
row.remove();
}
}
});
}
});
</script>
|