问题描述
我正在制作一个 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 组件添加工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!