如何抑制退格时,日期字段日历是活跃的extjs 4,特别是在IE中

How to suppress the backspace when the datefield calendar is active in extjs 4 especially in IE

本文关键字:extjs 特别是 IE 活跃 日历 何抑制 日期 字段      更新时间:2023-09-26

当datefield组件处于打开/激活状态时,如何在ie浏览器中限制退格?因为每当我在日期字段日历打开后按退格键时,当前屏幕就会重定向到上一页。所以我想限制/抑制后退键当日历是活动的

点击这里进行测试

添加到应用程序启动功能

Ext.getDoc().on('keydown', function (e, t) {
if (e.getKey() == e.BACKSPACE && (!/^input$/i.test(t.tagName) || t.disabled || t.readOnly)) {
            e.stopEvent();
        }
}); // Original answer was missing the closing parenthesis and semi

当你打开日历时,它的基础日期选择器变得活跃,所以这就是你需要防止退格键的地方:

查看此处提琴:https://fiddle.sencha.com/#fiddle/88a

            xtype: 'datefield',
            anchor: '100%',
            fieldLabel: 'From',
            name: 'from_date',
            disableKeyFilter: true,
            maxValue: new Date(),
            listeners: {
                expand: function(field){
                    new Ext.util.KeyNav({
                        target: field.getPicker().getEl(),
                        scope: this,
                        backspace: {
                            fn: function(e){
                                e.stopEvent();
                            }
                        }
                    })
                }
            }
Ext.getDoc().on('keydown', function (e, t) {
if (e.getKey() == e.BACKSPACE && (!/^input$/i.test(t.tagName) || t.disabled ||      t.readOnly)) {
        e.stopEvent();
    }
}); // Original answer missing closing parenthesis and semicolon...