【发布时间】:2009-09-04 18:39:57
【问题描述】:
我的问题与在带有在 asp.net UpdatePanel 控件中刷新的工具提示的项目上使用 JQuery 工具工具提示插件 (http://flowplayer.org/tools/tooltip.html) 有关。问题是,在添加工具提示后,来自 UpdatePanel 的任何部分回发都会导致工具提示在任何已更新的 UpdatePanel 中停止工作。在部分回发之前,工具提示效果很好。下面是我如何向页面上的图像(和其他控件)添加工具提示的示例。为简单起见,省略了一些代码:
<script type="text/javascript">
//--call this to add tooltips to any element with a class of "tooltipHandle"
function createTooltip(){
// select all desired input fields and attach tooltips to them
$(".tooltipHandle").tooltip({
// place tooltip on the right edge
position: ['center', 'right'],
// a little tweaking of the position
offset: [-2, 10],
// use a simple show/hide effect
effect: 'toggle',
// custom opacity setting
opacity: 0.7
});
}
//--add tooltips after every postback (including partial AJAX postbacks)
function pageLoad(sender, args) {
createTooltip();
}
</script>
<html>
<!-- assume this UpdatePanel is updated from the code behind--!>
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="upPanelPrivateMediaList">
<ContentTemplate>
<img class="tooltipHandle" src="/images/questionMark.gif"/>
<div class="tooltip">SOME GREAT TOOLTIP CONTENT</div>
</ContentTemplate>
</asp:UpdatePanel>
</html>
非常有趣的一点是,如果我在第一次加载页面时不调用“createToolTip()”,那么部分回发会正确地将工具提示添加到我的图像中,并且在我进行第二次回发之前它将一直有效。这意味着,如果工具提示已经存在,部分回发只会处理工具提示。在部分回发后手动调用 createToolTip() 不会使工具提示再次工作。
如果您有任何想法或需要澄清,请告诉我。提前致谢!!
【问题讨论】:
标签: .net asp.net javascript jquery