-
8 Dec 2011 3:03 PM #1
Answered: Changing Label Text
Answered: Changing Label Text
Simple form with a toggle for switching between metric and inch units. The unitSwitch function also changes all the labels to reflect the current units. The code below works until I uncomment the last line. Then the form hides all the fields except the unit toggle. This line of code is identical to the one three lines up, except the text, so I know it works on it's own.
Any idea's why it won't work?
Code:var unitSwitch = function(obj){ var tog = obj.getValue(); var modelCmp = Ext.getCmp('units'); if (tog) { modelCmp.labelEl.update('Units (Inch)'); Ext.getCmp('loadWeight').labelEl.update('Weight (lbs)'); } else { modelCmp.labelEl.update('Units (Metric)'); //Ext.getCmp('loadWeight').labelEl.update('Weight (kg)'); } }
Also, why does the font style change when the label is updated from load state? So far I haven't touched any css code from sencha.
Thanks
-
Best Answer Posted by AndreaCammarata
Hi runner.
What is the error you get if you uncomment the last line of code?
About the font change:
That's normal because actually updating the labelEl content in that way, you delete the span element which is inside each form label.
You should write:
orCode:modelCmp.labelEl.update('<span>Units (Inch)</span>');
Hope this helps.Code:modelCmp.labelEl.dom.firstChild.innerHTML = 'Hello';
-
9 Dec 2011 6:49 AM #2
Hi runner.
What is the error you get if you uncomment the last line of code?
About the font change:
That's normal because actually updating the labelEl content in that way, you delete the span element which is inside each form label.
You should write:
orCode:modelCmp.labelEl.update('<span>Units (Inch)</span>');
Hope this helps.Code:modelCmp.labelEl.dom.firstChild.innerHTML = 'Hello';
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata


Reply With Quote