YUI 工具提示未显示在面板顶部
当前在显示先前创建的 YUI 面板后,尝试让 YUI 工具提示显示在 YUI 面板顶部时遇到问题。问题是面板无法注册到覆盖管理器,因为这需要更改和测试大量代码,从而延长硬性截止日期。使其发挥作用的唯一方法是在显示面板后设置工具提示。问题是需要进行大量的代码更改才能附加另一个函数调用。我的问题是我希望我可以使用事件处理来使用 "showEvent"
但我似乎无法让它工作(我为字数表示歉意):
var panel_obj = new YAHOO.widget.Panel('someID', {
width: "700px",
height: "500px",
close: true,
draggable: false,
modal: true,
constraintoviewport: true,
visible: false,
fixedcenter: true
});
panel_obj.render();
var tooltip_name = 'newTooltip1';
var element_id = 'htmlElementIDToBecomeTooltip';
function createTooltip() {
window[tooltip_name] = new YAHOO.widget.Tooltip(tooltip_name, {
context: element_id,
xyoffset: [15, -15],
zIndex: 999
});
}
function successfulScenario() {
panel_obj.show();
createTooltip();
}
function failedScenario1() {
YAHOO.util.Event.addListener(
'someID',
"showEvent",
createTooltip
);
}
function failedScenario2() {
createTooltip();
panel_obj.show();
}
我似乎唯一的方法通过运行诸如 successfulScenario()
之类的东西来让它工作。我有 jQuery 背景,所以我仍在学习 YUI。我希望能够扩展(子类)YAHOO.widget.Panel 的 show()
函数来调用 createTooltip
但我不是一个大师,或者我可能需要更改一个非常大的代码库才能做到这一点。
Currently having a problem trying to get YUI Tooltips to display on top of a YUI Panel after it is shown that were previously created. The problem is is that the Panel cannot be registered to the overlay manager because it would require a TON of code to be changed and tested extending a hard deadline. The only way to get this to work is to setup the Tooltips after the Panel is shown. Problem there is the amount of code changes that would have to be done to attach another function call. My problem is that I was hoping that I could use the event handling to use "showEvent"
but I cannot seem to get it to work (I apologize for word count):
var panel_obj = new YAHOO.widget.Panel('someID', {
width: "700px",
height: "500px",
close: true,
draggable: false,
modal: true,
constraintoviewport: true,
visible: false,
fixedcenter: true
});
panel_obj.render();
var tooltip_name = 'newTooltip1';
var element_id = 'htmlElementIDToBecomeTooltip';
function createTooltip() {
window[tooltip_name] = new YAHOO.widget.Tooltip(tooltip_name, {
context: element_id,
xyoffset: [15, -15],
zIndex: 999
});
}
function successfulScenario() {
panel_obj.show();
createTooltip();
}
function failedScenario1() {
YAHOO.util.Event.addListener(
'someID',
"showEvent",
createTooltip
);
}
function failedScenario2() {
createTooltip();
panel_obj.show();
}
The only way I have seem to get it working is by running something like successfulScenario()
. I'm coming from a jQuery background so I'm still learning YUI. I would love to be able to just extend (subclass) YAHOO.widget.Panel's show()
function to call createTooltip
but I'm not that much of a guru or I would probably need to change a very large codebase to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用工具提示配置的“容器”属性(因此容器将是面板的元素):
这是快速解决方案,使用显示事件和/或扩展类会很好,但如果您仍然需要帮助,则必须运行,我会回来检查(还要检查我用您的代码制作的示例 http://jsfiddle.net/3GWaM /2/ )。
try using the "container" property for the tooltip config (so the container would be the panel's element):
This is the quick solution, using the show event and/or extending the class would be nice but gotta run, if you still need help, I'll check back (also check the example that i made with your code http://jsfiddle.net/3GWaM/2/ ).
这将确保工具提示 div 在对话框内创建,而不是在文档正文中,确保它不会出现在对话框下方。
另外,如果您想扩展面板类,只需执行以下操作
This will ensure the that the tool tip div is created inside the dialog box, instead of in the document body, ensuring it does not appear below the dialog box.
Also, if you want to extend the panel class just do the following