-
2 Nov 2008 9:30 AM #1
Help tip on text field
Help tip on text field
Hi,
Is there a way to display a help tip next to a text field?
for example I can do this easy with a tool bar...
Can I do something similar with a text field in a form?Code:tbar: [{ text: 'Add new site', tooltip: 'Add a new site to your site list', ...
Cheers,
Alex
-
2 Nov 2008 10:23 AM #2
This code adds tooltip-functionality to all formfields:
Set the tip-text with:Code:Ext.override(Ext.form.Field, { afterRender : Ext.form.Field.prototype.afterRender.createSequence(function() { var qt = this.qtip; if (qt) { Ext.QuickTips.register({ target: this, title: '', text: qt, enabled: true, showDelay: 20 }); } }) });
Code:qtip: 'This is my tooltip-text'
-
2 Nov 2008 1:34 PM #3
-
17 Nov 2008 4:18 AM #4
What about checkboxes??
What about checkboxes??
I'm doing something similar, but I find that the tip doesn't appear on any of my checkboxes, even though they're Ext.form.Field-derived...
Any clues? (I can see that the tip is being set, just never appears - is checkbox'smouseover event overridden somewhere?)
Code:Ext.onReady(function() { // form field tooltips Ext.override(Ext.form.Field, { afterRender: Ext.form.Field.prototype.afterRender.createSequence( function() { var tt = this.tooltip; if (tt && tt.tip) { Ext.QuickTips.register({ target: this, text: tt.tip, enabled: true }); } }) });
-
9 Jan 2009 2:25 PM #5
Does anyone know if the above override would work when using applyTo to associate with an existing HTML element?
Loaded question as I've used the override and there's no change in the behaviour. As far as I can see there's no reason why it wouldn't work?
This is a legacy app and hopefully the last one I'll ever maintain that's not fully Ext'd.
-
10 Jan 2009 12:58 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
The example code is actually wrong. It uses the component as the target, but it should use the element of the target, e.g.
This is also a problem with checkboxes and radios, because the main element is a hidden input.Code:target: this.getEl()
For checkboxes and radios you should probably use:
So you end up with something like:Code:target: this.imageEl
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; } });
-
9 May 2009 3:56 AM #7
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:Like this:Code:this.el.dom.qclass = '';
It removes the qclass element from the dom so you get your normal qtip backCode: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; } });
-
14 May 2009 6:49 AM #8
ok maybe its me but i can't put this to work O.o
just pasted the code on Condor post at the begining of my file
and have in a form:
nothing happens...no errors but no tip...Code:{ xtype: 'textfield', name: 'valor_orc', fieldLabel: 'Valor Orçamentado(€)', qtip: 'This is my tooltip-text', readOnly : false }
-
14 May 2009 11:58 AM #9Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
And did you call Ext.QuickTips.init() ?
-
15 May 2009 2:54 PM #10
yes i did...
but since it haven't worked i searched other solution and found this
http://extjs.com/forum/showthread.php?t=36642
edited a little to my own needs...
PS: if you could answer the question i have there it was great


Reply With Quote