2009-12-10 35 views
0

我得到了一個帶有中繼器的updatepanel。它顯示我從日曆中獲得的不同事件。在中繼器的updatepanel中的jquery對話框

現在它要做的是我點擊一個事件,它應該顯示在一個jQuery對話框中。

現在,如果我不使用updatepanel,但它只是不會工作,這很好。

我一直在尋找它昨天有一段時間了,我看到了一些文章,但我還是老樣子不會得到我正在尋找解決方案..

$(document).ready(function() {     
       $("#btnCheck").click(function(evt) { 
        evt.preventDefault();        

        $(".dialog").dialog({ height: 700, width: 600, 
closeOnEscape: true, title: 'prev' }).dialog("open"); 
       });   
      }); 

 <div class="calendar_event_div"> 
      <asp:Repeater ID="repContent" runat="server" OnItemDataBound="repContent_OnItemDataBound" OnItemCommand="repContent_OnItemCommand"> 
       <ItemTemplate>       
        <asp:Literal ID="lbnEvent" runat="server" /> 
        <asp:Literal ID="litEventBody" runat="server" /> 
       </ItemTemplate> 
      </asp:Repeater> 
     </div> 

    </ContentTemplate> 
</asp:UpdatePanel> 
+0

「對話框」類的元素在哪裏? – matpol 2009-12-10 08:46:34

回答

1

嘗試使用livequery。

$("#btnCheck").live("click", function(evt){ 

    // your code 

}); 

此方法效果非常的行爲類似於jQuery的綁定方法,但有一個重要的區別:當您綁定一個「活」的事件,將結合由更新面板控件加載所有當前和未來元素。

+0

非常感謝。 – 2009-12-10 08:51:39

+0

我會很快帶回解決方案 – 2009-12-10 09:40:56

2

嘗試註冊您的JavaScript與ScriptManager.RegisterScriptBlock(...),這將導致js在更新面板內被燒燬。

你也可以玩現場指揮。 Live將通過選擇器留意任何新元素,並將事件分配給該選擇。

$("#btnCheck").live("click", function(){ 
} 
+0

感謝您的回答Johan,我會盡快查看Scriptmanager。我不知道 – 2009-12-10 08:52:27

+1

爲RegisterScriptBlock +1,你實際上提前2分鐘回答。 – 2009-12-10 08:54:13