当托管在 UpdatePanel 中的控件上时,Jquery Colorbox 在关闭后不显示

发布于 2024-12-14 10:47:34 字数 1065 浏览 0 评论 0原文

所以我有一个用于 document.ready 函数的 Colorbox 设置:

$(document).ready(function () {
    $('#btnMyButton').colorbox({
        href: "./Modals/MyModal.aspx",
        iframe: true,
        height: 450,
        width: 550,
        opacity: .60,
        overlayClose: false,
        escKey: false,
        onClosed: function () {
            var mypage = Sys.WebForms.PageRequestManager.getInstance();
            mypage._doPostBack('upGrid', '');
        }
    });
});

在关闭 colorbox 时,我会回发到我的更新面板(upGrid)。在 MyModal 中,我有一个关闭颜色框的按钮,如下所示:

<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="parent.$.fn.colorbox.close(); return false;" CssClass="button cancel" />

更新面板包含一个网格,颜色框引导用户进入上传页面。如果他们成功上传文件,程序就会解析数据以填充网格。因此,当调用 colorbox 的 OnClosed 时,应该更新网格。

如果用户单击 btnMyButton 并继续单击模态上的 btnCancel,他们将无法再次单击 btnMyButton 以使颜色框再次加载模态。如果我将 btnMyButton 移到更新面板之外,它可以正常工作,但我希望更新面板内的 btnMyButton 能够处理隐藏/显示它,具体取决于用户是否已经上传了他们不应该看到的文件。

有没有人遇到/解决了在 ASP.NET 更新面板中关闭后 colorbox 无法重新显示的任何问题?

So I have a Colorbox setup for the document.ready function:

$(document).ready(function () {
    $('#btnMyButton').colorbox({
        href: "./Modals/MyModal.aspx",
        iframe: true,
        height: 450,
        width: 550,
        opacity: .60,
        overlayClose: false,
        escKey: false,
        onClosed: function () {
            var mypage = Sys.WebForms.PageRequestManager.getInstance();
            mypage._doPostBack('upGrid', '');
        }
    });
});

On close of the colorbox I do a postback to my update panel (upGrid). In MyModal I have a button that closes the Colorbox as such:

<asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick="parent.$.fn.colorbox.close(); return false;" CssClass="button cancel" />

The update panel contains a grid and the colorbox leads a user to an upload page. If they succesfully upload a file the program parses the data to fill in the grid. So when the OnClosed of the colorbox is called the grid should be updated.

If the user clicks btnMyButton and proceeds to click btnCancel on the Modal they are unable to click btnMyButton again to have the colorbox load the Modal again. If I move btnMyButton outside of the update panel it functions fine, but I wanted btnMyButton inside the update panel to handle hiding/showing of it depending on if the user has already uploaded a file they shouldn't see it.

Has anyone ran into/solved any issues with colorbox not redisplaying after close inside an ASP.NET update panel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲娇萝莉攻 2024-12-21 10:47:34

$(document).ready() 和 pageLoad() 不是一样!

在每次部分回发后也会调用它。基本可以发挥作用
作为 Application.Init 和的组合
PageRequestManager.EndRequest。

function pageLoad()
{
   $('#btnMyButton').colorbox({
        href: "./Modals/MyModal.aspx",
        iframe: true,
        height: 450,
        width: 550,
        opacity: .60,
        overlayClose: false,
        escKey: false,
        onClosed: function () {
            var mypage = Sys.WebForms.PageRequestManager.getInstance();
            mypage._doPostBack('upGrid', '');
        }
    });

}

$(document).ready() and pageLoad() are not the same!

It is also called after every partial postback. It basically functions
as a combination of Application.Init and
PageRequestManager.EndRequest.

function pageLoad()
{
   $('#btnMyButton').colorbox({
        href: "./Modals/MyModal.aspx",
        iframe: true,
        height: 450,
        width: 550,
        opacity: .60,
        overlayClose: false,
        escKey: false,
        onClosed: function () {
            var mypage = Sys.WebForms.PageRequestManager.getInstance();
            mypage._doPostBack('upGrid', '');
        }
    });

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文