在 asp.net 的 GridView 中使用 ColorBox

Using ColorBox inside a GridView in asp.net

本文关键字:ColorBox GridView asp net      更新时间:2023-09-26

我正在使用 ColorBox 库作为GridView行内的链接,但colorbox没有显示弹出窗口,但它重定向到页面。如果我将相同的链接带到外部,它会打开colobox窗口..为什么?

打开彩盒窗口的链接:

<a id="ctl00_ContentPlaceHolder1_gvFSuper_ctl07_HyperLink1" href="AddStaff.aspx" class="showColorBox">Test</a>

JavaScript:

 jQuery(document).ready(function ($) {
        $(".showColorBox").colorbox({ iframe: true, innerWidth: 800, innerHeight: 400 });
    });

在您尝试为其分配颜色框时,文档中是否存在该链接? 否则,您可能必须使用事件委派。 例如:

$('document').on('click', '.showColorBox', function(e){
    $.colorbox({href: this.href, iframe: true, innerWidth: 800, innerHeight: 400})
    e.preventDefault();
});