改变文本字段的颜色聚焦ExtJs

Change Textfield colour on focus ExtJs

本文关键字:聚焦 ExtJs 颜色 文本 字段 改变      更新时间:2023-09-26

我试图改变一个文本字段的颜色,当用户把光标放在它,更容易让用户找到文本字段。

我在另一篇文章中看到如何用css规则改变颜色,我在API中发现了fieldCls和focusCls来改变颜色,但它不起作用,我知道问题是焦点事件没有过滤,

按钮定义:

xtype:'textfield',
focusCls:'red',
fieldCls:'green',
listener: {
    'focus':function(){
        Ext.Msg.Alert('Focus','TextField have focus'); //This don't run
    }
}
CSS规则:

.red {
    background-image: none;
    background-color:#ff0000 !important;
}
.green {
    background-image: none;
    background-color:#00ff00 !important;
}

我做了这个测试的提琴:http://jsfiddle.net/FabioJCosta/3ZZcZ/547/

即使当我用按钮文本框强制焦点时。焦点(假,200);焦点事件没有触发。

我希望这对其他人有帮助。

谢谢

如果我理解这个问题,你不需要jQuery。

.green:focus {
    background-image: none;
    background-color:#ff0000 !important;
}
.green {
    background-image: none;
    background-color:#00ff00 !important;
}