Unplanned
Last Updated: 16 Apr 2021 17:07 by Akesh Gupta
Travis
Created on: 16 Apr 2020 05:18
Category: Dialog
Type: Feature Request
6
Predefined Kendo Alert should support chaining

kendo.alert should be able to return a promise.

Consistency is so import in these types of frameworks.

2 comments
Akesh Gupta
Posted on: 16 Apr 2021 17:07
If you replace the following code in kendo.dialog.js, it will behave as expected; modified code is in bold. It should start around line 706 depending on your version.

var Alert = PopupBox.extend({
            _init: function (element, options) {
                var that = this;
                PopupBox.fn._init.call(that, element, options);
                that.wrapper.addClass(KALERT);
                that.result = $.Deferred();
            },
            options: {
                name: 'Alert',
                modal: true,
                actions: [
                    {
                        text: '#: messages.okText #',
                        primary: true,
                        action: function (e) {
                            e.sender.result.resolve();
                        }
                    }]
            }
        });
        kendo.ui.plugin(Alert);
        var kendoAlert = function (text) {
            var alertDialog = $(templates.alert).kendoAlert({ content: text }).data('kendoAlert').open();
            return alertDialog.result;
        };
ADMIN
Alex Hajigeorgieva
Posted on: 31 Dec 2020 09:09

Hi, Travis,

Until we have implemented promises, you may programmatically bind to the hide event of the alert:

kendo.alert("My Alert!").bind("hide", function(){
   console.log("the alert was hidden by the user")
});

Here is a sample Dojo that demonstrates this in action:

https://dojo.telerik.com/uxIyEKuJ/2

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.