2011-10-05 95 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