[英]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.