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

Disable Esc key on Kendo Window Popup

2 Answers 1028 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sagar
Top achievements
Rank 1
Sagar asked on 27 Jun 2014, 12:18 PM
I am using KendoUI controls with JavaScript with MVC. I have a popup window create by "kendoWindow". its working fine, but when i press ESC key it will automatically close. I want to disable the ESC key so that window popup can be only closed by Cancel button or close button.

Here is my Kendo Window code.

var  wndEditClient= $("#divEditClient")
        .kendoWindow({
            title: "Edit Client",
            modal: true,
            visible: false,
            resizable: false,
            width: 450,
            actions: ["Close"]
        }).data("kendoWindow");
 
wndEditClient.open();
I tried JavaScript keypress event and all that but does not work.

$(document).bind("keypress", function (e) {     
       if (e.keyCode == 27) {
           e.preventDefault();
       }
   });
Please Suggest.

2 Answers, 1 is accepted

Sort by
0
Sagar
Top achievements
Rank 1
answered on 28 Jun 2014, 05:39 AM
I found my answer 

Put this before including your first Kendo Window directive:

$(function () {
    kendo.ui.Window.fn._keydown = function (originalFn) {
        var KEY_ESC = 27;
        return function (e) {
            if (e.which !== KEY_ESC) {
                originalFn.call(this, e);
            }
        };
    }(kendo.ui.Window.fn._keydown);
});
It perfectly works for me :)
0
Peeter
Top achievements
Rank 1
answered on 21 Jul 2016, 02:01 PM
Thanks Sagar, works for me!.
Tags
General Discussions
Asked by
Sagar
Top achievements
Rank 1
Answers by
Sagar
Top achievements
Rank 1
Peeter
Top achievements
Rank 1
Share this question
or