This is a migrated thread and some comments may be shown as answers.

Confirm Dialog that returns a value

1 Answer 2390 Views
Dialog
This is a migrated thread and some comments may be shown as answers.
sam
Top achievements
Rank 1
Veteran
sam asked on 30 Jul 2020, 03:03 AM

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.}

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 03 Aug 2020, 05:07 PM

Hello Sam,

The Kendo UI dialogs are not capable of stopping javascript execution like the default javascript confirm. Thus, they are not a replacement of the default confirm.

With the Kendo UI Confirm dialog you can check the whether the user has clicked "ok" or "cancel" and execute some choice dependent logic only the "ok" callback: https://dojo.telerik.com/usiraBUR

Regards,
Ivan Danchev
Progress Telerik

Tags
Dialog
Asked by
sam
Top achievements
Rank 1
Veteran
Answers by
Ivan Danchev
Telerik team
Share this question
or