admin管理员组文章数量:1323355
I'm using Uikit with Angularjs and i need create possibly a directive that prevent the closing of the Modal when i press esc button. I tried with this way:
mainApp.directive('ngEsc', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress keyup", function (event) {
if(event.which === 27) {
event.preventDefault();
}
});
};
});
And then put the directive on the modal
Test modalBut it still closes. Is there any other way?
I'm using Uikit with Angularjs and i need create possibly a directive that prevent the closing of the Modal when i press esc button. I tried with this way:
mainApp.directive('ngEsc', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress keyup", function (event) {
if(event.which === 27) {
event.preventDefault();
}
});
};
});
And then put the directive on the modal
Test modalBut it still closes. Is there any other way?
Share Improve this question asked Mar 11, 2016 at 14:08 Atlas91Atlas91 5,90417 gold badges75 silver badges148 bronze badges3 Answers
Reset to default 6Below is how I fixed this issue in my angular 7 project;
uikit.modal("#modalR", { bgClose: false, escClose: false, modal: false, keyboard:false}).show(this.data)
for more information please visit link below https://github./uikit/uikit/blob/develop/src/js/core/modal.js#L15:L21
Have you tried to use the option keyboard:false
?
UIkit.modal("#modal element", {bgclose: false, keyboard:false}).show();
It worked in my case.
You can see the core of modal uikit as well: modal.js
You can try use "return false" instead of preventDefault:
mainApp.directive('ngEsc', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress keyup", function (event) {
if(event.which === 27) {
return false;
}
});
};
});
本文标签: javascriptUkit modal prevent close on escape buttonStack Overflow
版权声明:本文标题:javascript - Ukit modal prevent close on escape button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742130497a2422136.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论