2016-06-10 71 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