View Full Version : Extending checkbox - multiple dom nodes. Is there a better way to write?

5 Mar 2015, 2:11 PM
This is an extended checkbox. We're basically wrapping the existing el inside a bunch of nested DIVs and adding a label. I was hoping there was a better way, maybe with a template, but couldn't really figure this out. The following works, but it's ugly.

onRender: function (ct, position) {
Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
this.wrap = this.el.wrap({tag:'span'});
this.wrap = this.wrap.wrap({ cls: 'iCB' });
this.wrap = this.wrap.wrap({ cls: 'iCBContainer ' + this.cls });
this.wrap.createChild({ tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label ', html: this.boxLabel
this.resizeEl = this.positionEl = this.wrap;