最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Disable Esc key on Kendo Window Popup - Stack Overflow

programmeradmin7浏览0评论

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();

Please Suggest.

I tried JavaScript keypress event and all that but does not work.

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

Tried this but not working.

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();

Please Suggest.

I tried JavaScript keypress event and all that but does not work.

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

Tried this but not working.

Share Improve this question asked Jun 27, 2014 at 12:08 sagar43sagar43 3,4643 gold badges31 silver badges49 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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);
});

(demo)

发布评论

评论列表(0)

  1. 暂无评论