我有一个jsp文件。当用户单击删除按钮时,我需要添加确认对话框
目前脚本有简单的确认,但我想要 kendo ui 确认框。我不确定jsp文件中的确认框是如何的。
function deleteRow(rowdata) {
if(confirm("Are you sure want to delete this record ?")){
if(finalRowval){
$.ajax({
type : 'DELETE',
url : "${pageContext.request.contextPath}/mvc/abc" + finalRowval.id + "/xyz",
dataType : 'text/html',
data : "",
async : true,
});
}
}
}
您需要修改 deleteRow 函数才能使用 Kendo UI 对话框。
function deleteRow(rowdata) {
// Create a Kendo UI Dialog
$("<div></div>").kendoDialog({
width: "450px",
title: "Confirm",
closable: false,
modal: true,
content: "<p>Are you sure want to delete this record?</p>",
actions: [
{ text: 'Cancel' },
{
text: 'Delete',
primary: true,
action: function(e) {
// Delete action confirmed
if(rowdata){
$.ajax({
type: 'DELETE',
url: "${pageContext.request.contextPath}/mvc/abc" + rowdata.id + "/xyz",
dataType: 'text/html',
data: "",
async: true,
success: function(response) {
// Handle success response
},
error: function(xhr, status, error) {
// Handle error response
}
});
}
}
}
]
}).data("kendoDialog").open();
}