繁体   English   中英

简单的jQuery模式弹出窗口未显示在gridview按钮上

[英]simple jQuery modal popup not showing on gridview button click

我已经将bPopup用作jquery plugin.link是: http ://www.jqueryscript.net/lightbox/Lightweight-jQuery-Modal-Popup-Plugin-bPopup.html

这是带有按钮字段的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()未显示。 以下是我遇到的错误的屏幕截图。

控制台错误的屏幕截图

将插件添加到页面底部

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

我认为您的选择器对于该按钮是错误的,应该是:

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

Web表单在ID后面加上您指定的ID,而不是在选择器要查找的ID前面加上前缀。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM