如何在ExtJS组件中添加工具提示? [英] How should I add a tooltip to an ExtJS Component?
问题描述
我正在制作一个ExtJS组件,我希望它使用QuickTips工具提示。如果我使用DomHelper做一个元素,我可以设置一个工具提示,没有汗水。但是,如果我创建一个组件,如
I'm making an ExtJS Component, and I want it to use a QuickTips tooltip. If I make an element using DomHelper, I can set a tooltip, no sweat. If, however, I make a Component, like
new BoxComponent({
qtip: "This is a tip"
});
没有任何反应。我也试过命名财产工具提示,但没有运气。有没有正确的方法来做到这一点?我现在所在的黑客是
nothing happens. I've also tried naming the property "tooltip", but no luck. Is there a right way to do this? The hack I have in place now that works is
new BoxComponent({
qtip: "This is a tip",
listeners: {
rendered: function(c){
Ext.QuickTips.register({
target: c.getEl(),
text: c.qtip
}
}
});
我觉得那么这个不能是正确的,我想我可以自动地扩展Component来做这件事情,但是看起来好像是一个很常见的情况,我应该可以这样做,而不会像这样在引擎盖下戳。
I feel like that can't be right. I guess I could just extend Component to do that automatically, but it seems like a common enough case that I should be able to do it without poking under the hood like this.
推荐答案
我认为你做的绝对正确,我真的看不到QuickTips在任意组件中的需要,特别是在容器中,因为这可能会导致同一组件中的多个工具提示。
I think you're doing it absolutely right. I really don't see the need for QuickTips in arbitrary Components, particularly in Containers, since that might lead to multiple tooltips within the same Component.
这篇关于如何在ExtJS组件中添加工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!