关于Charisma模板禁用弹出对话框按ESC键自动隐藏的方法(强迫症系列二)
- 强迫症诱因
- 有病要吃药
- 找到药了
- 病好了
强迫症诱因
还是那年的某一天,找到一个非常棒的前端模板,真的非常棒
官方网站链接 https://usman.it/free-responsive-admin-template/
Demo pages
Charisma is a full featured, free, premium quality, responsive, HTML5 admin template (or backend template) based on Bootstrap 3 from Twitter, it comes with 9 different themes to suit your style and application type.
Charisma helps you minimize the repeat work you have to do on you projects. You can re-use Charisma as a base or as a package for your admin panel. It’s free for personal and commercial use and you can use it in multiple sites.
整个模板都非常好用,非常炫,可~~~~个人使用习惯里,将弹出的对话框作为另一种可提供用户输入的界面,那么问题来了,当输入错误,比如:正在用拼音打字时,某个字的拼英打错了,很多人的习惯就是直接按一下ESC键,然后再输入,本人就是那很多人的代表,模板默认ESC键为关闭对话框,好烦!真的好烦!打错一个字的拼音很可能导致前面输入的全部要重新打一遍,死可忍,连续打错两遍后就不能忍了!

有病要吃药
刚开始的时候没搞清楚这个模板的底细,走了好多冤枉路,真的,病重了!!!!
找到药了
ESC键的key值是27,那么就在模板的各种js文件里找,找,找,找…
这个模板使用的还是Bootstrap框架,对话框也是Bootstrap提供的,在bower_components\bootstrap\dist\js\bootstrap.min.js里找到了,源码如下:
27==a.which&&this.hide()
注释掉
/*27==a.which&&this.hide()*/
搞定!!
病好了
这下随便怎么按ESC键,对话框都不会关闭掉了,一下就轻松了,妈妈再也不用担心我拼音要打两遍了!