Search code examples
javascriptextjstooltip

add a tooltip to an EXTJS Button


I am trying to add a tooltip to my button, I tried differents ways, but nothing happen when i put the mouse under the button, this is a part of my code when i tried to add this tool tip this when i created the button called guestButton

 {
    xtype : 'button',
    id : 'guestButton',
    text : 'Guest User',
    handleMouseEvents: true,
    width : 80,
    x : 70,
    y : 150,
    formBind : false,                       
    handler : function() {
    this.up().LoginGuest();
    }

and here when i tried to create the tooltip

    var tooltips = [{
            target: 'guestButton',
            html: 'A very simple tooltip'
        }];
Ext.each(tooltips, function(config) {
        Ext.create('Ext.tip.ToolTip', config);
    });  

Ext.QuickTips.init();

Thanks !


Solution

  • Another way of adding tooltips at render.
    @chrisuae is right , but it had not worked for me also.
    What worked was creating tooltip on render of element :

       {
            xtype : 'textareafield', 
            grow : true,
            fieldLabel : 'E-Mail-Adressess'
            itemId : 'email',
            afterLabelTextTpl : required,
            allowBlank : false,
            listeners : {
                render: function(c) {
                Ext.create('Ext.tip.ToolTip', {
                    target: c.getEl(),
                    html: 'You can enter multiple emails here'
                });
               }    
            }
        }