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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With