我必须在模糊事件中隐藏相同的字段。
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/