手动移动焦点时Combo不会模糊
Combo doesn't blur when manually shifting focus
我有一个组合框,用于在用户选择值后立即将焦点转移到另一个表单元素,配置如下:
new Ext.form.ComboBox({
// ...
listeners: {
select: function( a, record ) {
if ( typeof( record ) == 'undefined' ) {
return;
}
if ( !Ext.getCmp('input-name').getValue() ) {
Ext.getCmp('input-name').focus();
}
},
blur: function() {
console.log('blurred');
},
render: function( field ) {
if ( !config.activity ) {
field.onTriggerClick();
}
}
},
// ...
});
然而,奇怪的事情发生了。"input-name"表单字段受到关注,我可以开始在其中输入,但组合字段永远不会模糊。它仍然具有"x-form-focus"样式,并且"blur"事件永远不会被触发。只有当我用鼠标点击另一个字段时,组合才会模糊。
有谁知道发生了什么事,我该如何规避?
我是这样解决的:
listeners: {
select: function( a, record ) {
if ( typeof( record ) == 'undefined' ) {
return;
}
/**
* There's some weird stuff going on in the combo control, that causes it not to blur when shifting focus,
* so we have to do it manually. This action has to be deferred, because the control is going to refocus
* itself at the end of the function firing this event (onViewClick()).
*/
this.moveFocus.defer( 100, this );
},
render: function( field ) {
field.moveFocus = function() {
if ( !Ext.getCmp('input-name').getValue() ) {
Ext.getCmp('input-name').focus();
this.triggerBlur();
}
};
if ( !config.activity ) {
field.onTriggerClick();
}
}
},
当任何代码片段作为事件的一部分被执行并且导致触发其他事件时,则不会触发新事件。onBlur应该只在用户在UI中执行某些操作时执行,因为组合框会失去焦点,而不是通过编程方式使字段失去焦点。
相关文章:
- 模糊事件的Javascript测试
- 将事件聚焦/模糊在可编辑内容的元素上
- 如何像模糊图像一样模糊iframe
- 奇怪的日期选择器行为,与模糊有关
- 角度ui选择标记模糊时丢失文本输入
- 为什么我的.blur()代码只处理第二个模糊
- Primefaces编辑器模糊事件
- jQuery模糊时验证文本字段
- 角度指令中的模糊无法正常工作
- 如何通过css模糊除当前悬停之外的所有图像
- ContentEditable Div模糊事件
- MVC-模糊事件的远程验证
- 密码模糊事件未显示
- AngularJS内容可编辑模糊输入
- 如果模糊事件的任何一个子项获得焦点,请阻止启动模糊事件
- Javascript:联合焦点模糊
- 为什么不'当使用模糊时,点击工作
- 在模糊 javascript 上格式化为 hh:mm 输入
- 在Sinatra(ruby)中实现JS模糊搜索
- 手动移动焦点时Combo不会模糊