Sử dụng code:
html
1 <script type="text/javascript">2 //Delete event handler.3 $("body").on("click", "#WebGrid TBODY .Delete", function () {4 if (confirm("Do you want to delete this row?")) {5 var row = $(this).closest("tr");6 var customerId = row.find(".label").html();7 $.ajax({8 type: "POST",9 url: "/Home/DeleteCustomer",10 data: '{customerId: ' + customerId + '}',11 contentType: "application/json; charset=utf-8",12 dataType: "json",13 success: function (response) {14 if ($("#WebGrid TBODY tr").length == 1) {15 row.find(".label").html("");16 row.find(".text").val("");17 row.find(".link").hide();18 } else {19 row.remove();20 }21 }22 });23 }24 });25</script>
