I know most users have asked this, But i cant seem to get it right. I have button that needs to change color on initialize() function. here is an example of one.
{
xtype:"button",
id:"showme_BTN",
baseCls:"home-round-btns",
html:'<img src="resources/icons/show_me.svg">'
},
My initialize function(), this runs as soon as the app launches.
listeners: {
initialize: function(){
//console.log("initialize() works");
Ext.getCmp('showme_BTN').removeCls('home-round-btns'); //remove old class
Ext.getCmp('showme_BTN').addCls('home-round-btns-red'); // add new class
}
}
You may ask why i want to do this, I want load personalized colors on different users, Thank You
addCls
function Adds a CSS class to the top level element representing this component. It will not add the class in baseCls
it will add class in cls
.
EDIT Your button code should be:
{
xtype:"button",
id:"showme_BTN",
cls:"home-round-btns",
html:'<img src="resources/icons/show_me.svg">'
},
based on ankit chaudhary
I know what you mean,
If you really have to go that way you need to:
var btn = Ext.Viewport.down('#showme_BTN');
btn.element.dom.classList.remove('home-round-btns');
btn.element.dom.classList.add('home-round-btns-red');
Further improvements:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.