I need a kendo confirm dialog that returns a value.
If OK button is clicked then i need to perform some actions.
If Cancel button is clicked then do nothing.
I have a kendodialog function already created with "OK" and "Cancel" button but it does not behave the way I expect it to behave.
I need the code to wait till the user selects a respoonse and not do any other processing till a user selects any input which would be the case for a normal javascript confirm dialog.
Any example demonstrating the same would be extremely helpful.
01.
if (displayConfirmDialog("Do you want to continue ?")) {
02.
// do something if function returns "TRUE" i.e. the OK button is clicked
03.
}
04.
05.
// Test function
06.
function displayConfirmDialog(contentText) {
07.
var response = false;
08.
let dialogDiv = $('<
div
/>').appendTo('body');
09.
dialogDiv.attr('id', 'displayDialog');
10.
$("#displayDialog").kendoDialog({
11.
width: "450px",
12.
closable: false,
13.
modal: true,
14.
content: "<
p
id
=
dialogContent
>" + contentText + "</
p
>",
15.
buttonLayout: "normal",
16.
actions: [
17.
{
18.
text: "Ok",
19.
action: function (e) {
20.
closeAndDestroyNotificationDialog(e.sender);
21.
response = true;
22.
},
23.
primary: true
24.
},
25.
{
26.
text: "cancel",
27.
action: function (e) {
28.
closeAndDestroyNotificationDialog(e.sender);
29.
}
30.
}
31.
],
32.
})
33.
34.
$(".k-window-titlebar").addClass("warningDialogTitleBar");
35.
$(".k-dialog-title").addClass("warningDialogTitle");
36.
37.
return response;
38.
}