javascript - ExtJS 6 - 隐藏组件时停止事件委托(delegate)?

标签 javascript extjs extjs6 event-delegation

我必须在模糊事件中隐藏相同的字段。

Extjs 6 在组件隐藏方法上调用事件委托(delegate)。事件委托(delegate)将焦点恢复到具有焦点的最后一个字段

而且,我不想恢复焦点。有什么办法可以在隐藏 extjs 中的元素时停止事件委托(delegate)吗?

extjs 5 附带事件委托(delegate) - Delegated Events and Gestures in Ext JS 5

用于隐藏的方法 - https://docs.sencha.com/extjs/6.0/6.0.1-classic/#!/api/Ext.Component-method-onHide

ExtJS 源代码中的 onHide() 方法 - 检查 revertFocus()

onHide: function(animateTarget, cb, scope) {
    var me = this,
        ghostPanel, fromSize, toBox;
    if (!me.ariaStaticRoles[me.ariaRole]) {
        me.ariaEl.dom.setAttribute('aria-hidden', true);
    }
    // Part of the Focusable mixin API.
    // If we have focus now, move focus back to whatever had it before.
    me.revertFocus(); // this revert focus making probelm
    // Default to configured animate target if none passed
    animateTarget = me.getAnimateTarget(animateTarget);
    // Need to be able to ghost the Component
    if (!me.ghost) {
        animateTarget = null;
    }
    // If we're animating, kick off an animation of the ghost down to the target
    if (animateTarget) {
        toBox = {
            x: animateTarget.getX(),
            y: animateTarget.getY(),
            width: animateTarget.dom.offsetWidth,
            height: animateTarget.dom.offsetHeight
        };
        ghostPanel = me.ghost();
        ghostPanel.el.stopAnimation();
        fromSize = me.getSize();
        ghostPanel.el.animate({
            to: toBox,
            listeners: {
                afteranimate: function() {
                    delete ghostPanel.componentLayout.lastComponentSize;
                    ghostPanel.el.hide();
                    ghostPanel.setHiddenState(true);
                    ghostPanel.el.setSize(fromSize);
                    me.afterHide(cb, scope);
                }
            }
        });
    }
    me.el.hide();
    if (!animateTarget) {
        me.afterHide(cb, scope);
    }
},

最佳答案

你做错了,revertFocus()是一个主要问题根源。解决方案可能是:

blurEventFunction:function(cmp){
    cmp.previousFocus = null;
    cmp.hide();
}

关于javascript - ExtJS 6 - 隐藏组件时停止事件委托(delegate)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36687389/

相关文章:

javascript - ExtJS:修复两个工具栏元素上的图像

css - ExtJS - 如何设置禁用按钮的样式?

javascript - 我应该检查操作类型中是否有 'SUCCESS' 之类的关键字?

javascript - React-data-grid setScrollLeft 不是一个函数 - 固定列不起作用 - 自定义行渲染器

javascript - Extjs 4.1 : Ext. data.Store 记录没有加载到第二个 Ext.data.Store

javascript - 如何在 extjs 6 网格中调整列的大小添加 css 类

javascript - 如何创建具有动态数量的网格列的 TailwindCSS 网格?

javascript - 将 CSS 和 JS 限制为 Rails 引擎

javascript - Extjs网格单元格编辑器跳离单元格

javascript - TabPanel 选项卡上的 itemId 被框架设置为 "deleted"?