2011-10-05 53 views
0

我在更新面板中有3个按钮。他们每个人都使用qTip插件。在更新面板之外,它工作正常,但在点击后它不会消失。更新面板中的qTip jQuery插件无法正常工作

这里是我的代码

function pageLoad() { 


      $('.subindex a[title]').qtip({ 
       position: { 
        corner: { 
         target: 'topMiddle', 
         tooltip: 'bottomMiddle' 
        } 
       }, 
       style: { 
        name: 'cream', 
        padding: '7px 13px', 
        color: '#350608', 
        width: { 
         max: 210, 
         min: 0 
        }, 
        tip: true 
       } 
      }); 
} 

和更新面板

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
        <ContentTemplate> 

     <a title="Title"> 
     <asp:ImageButton ID="ImgOne" OnCommand="ImgOne_Click" runat="server" /></a> 
        <a title="Title2"> 
     <asp:ImageButton ID="ImgTwo" OnCommand="ImgTwo_Click" runat="server" /></a> 
<a title="Title2"> 
     <asp:ImageButton ID="ImgThree" OnCommand="ImgThree_Click" runat="server" /></a>  
        </ContentTemplate> 
       </asp:UpdatePanel> 

任何想法如何解决呢?

回答

0

当UpdatePanel更新它时会抛出标记并重新呈现它,因此您需要将jquery事件重新连接到新标记。您可以尝试使用实时或委托,也可以在面板更新后再次运行pageLoad函数。有一个jquery plugin that can help you do this,或者你可以使用一些MS JavaScript来自己做,像这样

$(function() { 
    pageLoad(); //initial call for your first page load 
    var prm = Sys.WebForms.PageRequestManager.getInstance(); 
    prm.add_endRequest(function() { 
     pageLoad(); //this will be called when an UpdatePanel.Update() occurs 
    }); 
}); 
在我看来

当然,下车WebForms和成asp.net的MVC将是一个更好的解决方案。

p.s.确保你在你的UpdatePanel上使用UpdateMode =“Conditional”,否则你会浪费你的时间开始。

p.p.s this is a newer version of that plugin i think