2016-06-10 64 views
0

我用bPopup在jQuery plugin.link是:http://www.jqueryscript.net/lightbox/Lightweight-jQuery-Modal-Popup-Plugin-bPopup.html簡單的jQuery模態彈出點擊

這是一個按鈕字段GridView的。

   <asp:GridView ID="gvwData" runat="server" 
        AllowPaging="True" AutoGenerateColumns="False" >                                                                  
        <Columns> 
         <asp:TemplateField HeaderText="preview"> 
         <ItemTemplate>        
          **<asp:Button id="mybutton" runat="server" Text="click"/>** 
         </ItemTemplate> 

         </asp:TemplateField> 

        </Columns> 
        <AlternatingRowStyle Width="220px" /> 
       </asp:GridView> 

這是JavaScript函數:

<script type="text/javascript"> 

     $(document).on("click", "[id*=mybutton]", function(e) { 

     e.preventDefault();  

      **$('#elementtopopup').bPopup();** 

}); (jQuery); 


</script> 

$( '#elementtopopup')bPopup()沒有顯示。以下是我收到的錯誤的屏幕截圖。

Screenshot of the console error

回答

0

我覺得你的選擇是錯誤的按鈕,應該是:

$(document).on("click", "[id$='mybutton']", function(e) { 
    // code 
}); 

Web表單後綴標識與您指定的ID而不是前綴您的選擇器正在尋找。

+0

是啊..我改變了這一點。同時我把所有與彈出(div,腳本)相關的代碼放在頁面的底部。替代使用我使用CssClass的按鈕的ID,最後它的工作。感謝您的幫助.. :) – Malika

+0

沒問題,你能把它標記爲回答嗎? – kmcoulson

0

插件添加到您的頁面的底部

<script src="jquery.bpopup-0.8.0.min.js"></script>//change it to the path of the js file 
+0

累了,但沒有工作。 – Malika

+0

你的系統上有jquery.bpopup-0.8.0.min.js嗎? – madalinivascu

+0

是的。 Malika