PDA

View Full Version : CheckBox Check listener 4.2 equivalent?



Csegota
17 Jun 2013, 8:37 AM
I'm trying to listen for when a user checks a Checkbox field, when they check the box, I would like to bold the corresponding label.

3.4 check listener code would have looks something like this



check: function (this, checked) {
if(checked){
this.container.addClass('myBoldCSS');
}
else {
this.container.removeClass('myBoldCSS');
}

The only 4.2 listener that seems to me like it has anything to do with listening for a check event is 'change', however that doesn't pass back a boolean.

How do I listen for when a checkbox is checked in Ext JS 4.2, and after that event fires, how can I change the CSS for the label associated with the checkbox.

Thanks!

friend
17 Jun 2013, 11:43 AM
The change event signature is:


change( checkbox, newValue, oldValue, eOpts)

So just do this, where newValue typically defaults to a boolean:



if(newValue) {
this.container.addClass('myBoldCSS');
}
else {
this.container.removeClass('myBoldCSS');
}

Csegota
18 Jun 2013, 11:33 AM
Worked thanks!

For anyone referencing this, in my actual code:
this.container.addClass('...') was actually implemented as checkbox.addCls('...');