
Originally Posted by
Condor
The example code is actually wrong. It uses the component as the target, but it should use the element of the target, e.g.
Code:
target: this.getEl()
This is also a problem with checkboxes and radios, because the main element is a hidden input.
For checkboxes and radios you should probably use:
Code:
target: this.imageEl
So you end up with something like:
Code:
Ext.override(Ext.form.Field, {
afterRender: Ext.form.Field.prototype.afterRender.createSequence(function(){
if(this.qtip){
var target = this.getTipTarget();
if(typeof this.qtip == 'object'){
Ext.QuickTips.register(Ext.apply({
target: target
}, this.qtip));
} else {
target.dom.qtip = this.qtip;
}
}
}),
getTipTarget: function(){
return this.el;
}
});
Ext.override(Ext.form.Checkbox, {
getTipTarget: function(){
return this.imageEl;
}
});
Sorry for kicking this thread, but I thought it could be useful.
I use this override for a settings page, the field labels are a short description of what the setting is about, but that's not always enough so I have a longer description as a tooltip (qtip) using this override.
When the field invalidates, the dom element gets a qclass of 'x-form-invalid-tip' and some other qtip text (the error): perfectly good behaviour. However, when you fix the error and clearInvalid() gets called, the dom element's qclass isn't removed, so you get your descriptive text back, but it's shown in an error type of qtip instead of the normal small, blue, iconless qtip.
So, long story short, I override the clearInvalid function with one extra line:
Code:
this.el.dom.qclass = '';
Like this:
Code:
Ext.override(Ext.form.Field, {
afterRender: Ext.form.Field.prototype.afterRender.createSequence(function() {
if(this.qtip) {
var target = this.getTipTarget();
if (typeof this.qtip == 'object') {
Ext.QuickTips.register(Ext.apply({
target: target
}, this.qtip));
} else {
target.set({
qtip: this.qtip
});
}
}
}),
clearInvalid: function(){
if(!this.rendered || this.preventMark){ // not rendered
return;
}
this.el.removeClass(this.invalidClass);
switch(this.msgTarget){
case 'qtip':
this.el.dom.qtip = '';
this.el.dom.qclass = '';
break;
case 'title':
this.el.dom.title = '';
break;
case 'under':
if(this.errorEl){
Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
}
break;
case 'side':
if(this.errorIcon){
this.errorIcon.dom.qtip = '';
this.errorIcon.hide();
this.un('resize', this.alignErrorIcon, this);
}
break;
default:
var t = Ext.getDom(this.msgTarget);
t.innerHTML = '';
t.style.display = 'none';
break;
}
this.fireEvent('valid', this);
},
getTipTarget: function() {
return this.el;
}
});
Ext.override(Ext.form.Checkbox, {
getTipTarget: function() {
return this.imageEl;
}
});
It removes the qclass element from the dom so you get your normal qtip back 