Y_Y
Y_Y

Reputation: 1295

Dynamically change ToolTip of a Tool object

Is there a way to change a tooltip text from a Tool placed in a panel? I looked at the ToolTip object and QuickTip but neither have a function like setTipText()

Thanks, Y_Y

Upvotes: 1

Views: 4867

Answers (2)

knighter
knighter

Reputation: 1227

I wasn't able to put an itemId on my tooltip, so I was able to dynamically update the tooltip of a tool this way:

var toolTip = Ext.get(tool.getEl().id + '-toolEl');
toolTip.set({ 
    'data-qtitle': 'New Tooltip Title', //this line is optional
    'data-qtip': 'Updated Tool Tip!' 
});

Upvotes: 5

harry
harry

Reputation: 702

I have two solutions for your problem!

  1. Change HTML-attribute

    toolTip=Ext.ComponentQuery.query('tooltip[itemId=myToolTip]')[0];
    toolTip.html = "This is the new text!";
    toolTip.setTitle("new Title");
    toolTip.render();
    
  2. Destroy the old one and make a new one...

    tooltip.destroy();
    var config = {
        target: 'bottomCallout',
        anchor: 'top',
        anchorOffset: 85, // center the anchor on the tooltip
        html: "Fancy new ToolTip with a totally different config..."
    };
    Ext.create('Ext.tip.ToolTip', config);
    

Upvotes: 3

Related Questions