首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >脚本在updatepanel中不能正常工作

脚本在updatepanel中不能正常工作
EN

Stack Overflow用户
提问于 2012-06-03 23:32:14
回答 1查看 838关注 0票数 2

我有一个用于显示工具提示的脚本

代码语言:javascript
复制
 function BindToolTip(){
        $('.toolTip').hover(
    function () {
        this.tip = this.title;
        $(this).append(
        '<div class="toolTipWrapper">'
            + '<div class="toolTipTop"></div>'
            + '<div class="toolTipMid">'
                + this.tip
            + '</div>'
            + '<div class="toolTipBtm"></div>'
        + '</div>'
    );
        this.title = '';
        this.width = $(this).width();
        $(this).find('.toolTipWrapper').css({ left: this.width - 22 })
        $('.toolTipWrapper').fadeIn(300);

    },
function () {
    $('.toolTipWrapper').fadeOut(100);
    $(this).children().remove();
    this.title = this.tip;
}
);
    }

aspx文件如下所示:

代码语言:javascript
复制
<asp:UpdatePanel ID="UpdatePanelAddNews" UpdateMode="Conditional" runat="server">  
<ContentTemplate>
 <script type="text/javascript">
             Sys.Application.add_load(BindToolTip);
  </script>    
   <div class="toolTip" title="This is a simple tooltip made with jQuery"></div> 
  <asp:UpdatePanel ID="UpdatePanelDate" runat="server">
      <ContentTemplate>                          
 <asp:DropDownList ID="DropDownListYearStart" runat="server" AutoPostBack="true"
  OnSelectedIndexChanged="OnSelectedStartDateChanged" CssClass="dropdown"> </asp:DropDownList>
     </ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

当我悬停div时,它正确地显示了工具提示,但在使用dropdownlist进行回发后,当我第一次悬停div时,它显示了两个工具提示,一个是空的,另一个工具提示后面有文本。当我第二次悬停时,它只显示空的工具提示。我知道如果从脚本中删除line: this.title =‘’,它将正常工作,但它将显示两个工具提示,我的自定义工具提示和默认的windows工具提示。如何解决?

EN

回答 1

Stack Overflow用户

发布于 2012-10-09 23:37:39

在ContentTemplate的最后编写您的脚本。喜欢,

代码语言:javascript
复制
<asp:UpdatePanel ID="UpdatePanelAddNews" UpdateMode="Conditional" runat="server">  
<ContentTemplate>    
<div class="toolTip" title="This is a simple tooltip made with jQuery"></div> 
<asp:UpdatePanel ID="UpdatePanelDate" runat="server">
  <ContentTemplate>                          
<asp:DropDownList ID="DropDownListYearStart" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="OnSelectedStartDateChanged" CssClass="dropdown"> </asp:DropDownList>
<script type="text/javascript">
         Sys.Application.add_load(BindToolTip);
</script>    
 </ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

希望能有所帮助。如果它解决了你的问题,别忘了给它加票。谢谢..:)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10871615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档