I have some records in jquery datatable and I have delete button for every record. I want to display an alert box "Are you sure want to delete this record?" on click of delete button before deleting the value. How can I achieve this?
table design
<table id="patientTable" class="table-hover table-bordered">
<thead>
<tr>
<th>Patient Name</th>
<th>Address</th>
<th>Date</th>
<th>Description</th>
<th>Amount</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
</table>
jquery code
@* Load datatable css *@
<link href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet" />
@* Load datatable js *@
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function () {
$('#patientTable').DataTable({
"ajax": {
"url": "/Patient/LoadData",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "Name", "autoWidth": true },
{ "data": "Address", "autoWidth": true },
{ "data": "Date", "autoWidth": true,
"render": function (value) {
if (value === null) return "";
var pattern = /Date\(([^)]+)\)/;
var results = pattern.exec(value);
var dt = new Date(parseFloat(results[1]));
return (dt.getMonth() + 1 + "/" + dt.getDate() + "/" + dt.getFullYear());
}
},
{ "data": "Description", "autoWidth": true },
{ "data": "Amount", "autoWidth": true },
{ "data": "ID", "width": "50px",
"render": function (id) {
return '<a href="/Patient/Edit/' + id + '">Edit</a>';
}
},
{ "data": "ID", "width": "50px",
"render": function (id) {
return '<a href="/Patient/Delete/' + id + '">Delete</a>';
}
}
]
});
});
</script>
Please guide me how to display alert like this
on click of delete button I'm new jquery datatable. Thanks in advance.
