-
26 Jun 2012 9:50 AM #1
Answered: How to dynamically change the background-color of a text area field ?
Answered: How to dynamically change the background-color of a text area field ?
Hi,
I want to dynamically change the background color of a text area field when a certain checkbox is checked.
Attached is my example attempt to do this:
textarea_bg_example.zip
Thanks,Yaron Yogev
IT Software Developer
-
Best Answer Posted by scottmartin
See if this will help:
Code:.red-editor textarea { background: none; background-color: red; padding-top: 5px; } .blue-editor textarea { background-color: blue; } Regards,Code:var form = Ext.create('Ext.form.FormPanel', { title : 'Sample TextArea', width : 400, bodyPadding: 10, renderTo : Ext.getBody(), items: [{ xtype : 'textareafield', grow : true, name : 'message', fieldLabel: 'Message', anchor : '100%', cls: 'red-editor' }] }); Ext.create('Ext.Button', { text: 'Click me', renderTo: Ext.getBody(), handler: function() { var ta = form.down('textareafield'); ta.addCls('blue-editor'); } });
Scott.
-
26 Jun 2012 11:45 AM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,190
- Vote Rating
- 195
- Answers
- 436
See if this will help:
Code:.red-editor textarea { background: none; background-color: red; padding-top: 5px; } .blue-editor textarea { background-color: blue; } Regards,Code:var form = Ext.create('Ext.form.FormPanel', { title : 'Sample TextArea', width : 400, bodyPadding: 10, renderTo : Ext.getBody(), items: [{ xtype : 'textareafield', grow : true, name : 'message', fieldLabel: 'Message', anchor : '100%', cls: 'red-editor' }] }); Ext.create('Ext.Button', { text: 'Click me', renderTo: Ext.getBody(), handler: function() { var ta = form.down('textareafield'); ta.addCls('blue-editor'); } });
Scott.
-
26 Jun 2012 9:58 PM #3
The CSS selector was the problem
The CSS selector was the problem
It works after the CSS class definition was modified.
The same CSS class definition was used with an ExtJS 3 text area field, and apparently in ExtJS 4 the text area field structure was changed so it became necessary to add the 'textarea' selector to the CSS class definition.
Thanks,Yaron Yogev
IT Software Developer


Reply With Quote