更改 SimpleModal 对话框中的内部 HTML?

发布于 2024-10-10 00:28:40 字数 1305 浏览 0 评论 0原文

我正在使用 jQuery 表单插件的 beforeSubmit 函数来关闭模式对话框,并且我希望随后弹出另一个模式对话框,其中包含提交表单的结果,因此我在 success 函数中放置了另一个模式并传递通过responseText...但是新的模式对话框永远不会弹出...我怎样才能让它弹出?我还想知道如何更改对话框的innerHTML。我尝试了dialog.data.html(responseText);和其他一些东西,但都不起作用。

这是表单提交的代码:

$('#member_ban_forum').ajaxForm( { 
    data: { member: member }, beforeSubmit: function() { 
        $.modal.close();
    },

    success: function (responseText) {
        $().delay(5000, function () {
            simpleModal(responseText);
        });
    }
});

这是我制作的 simpleModal 弹出函数的代码:

function simpleModal ( html ) {
    $(html).modal({
        containerCss:{
            height:340,
            width:450
        },

        onOpen: function (dialog) {
            dialog.overlay.fadeIn(350, function () {
                dialog.container.fadeIn(350, function () {
                    dialog.data.slideDown(350);
                });
            });
        },

        onClose: function (dialog) {
            dialog.data.slideUp(350, function () {
                dialog.container.fadeOut(350, function () {
                    dialog.overlay.fadeOut(350, function () {
                        $.modal.close();
                    });
                });
            });
        }
    });
}

I'm using the beforeSubmit function of the jQuery form pluggin in order to close a modal dialog, and I want another one to popup after-wards with the result of the form being submitted, so I put another modal in the success function and passing through the responseText... but the new modal dialog never pops up... how can I get it to pop up? I would also like to know how to change the innerHTML of the dialog box. I tried dialog.data.html(responseText); and some other stuff, but none of it worked.

Here's the code for the form submit:

$('#member_ban_forum').ajaxForm( { 
    data: { member: member }, beforeSubmit: function() { 
        $.modal.close();
    },

    success: function (responseText) {
        $().delay(5000, function () {
            simpleModal(responseText);
        });
    }
});

Here's the code for the simpleModal popup function I made:

function simpleModal ( html ) {
    $(html).modal({
        containerCss:{
            height:340,
            width:450
        },

        onOpen: function (dialog) {
            dialog.overlay.fadeIn(350, function () {
                dialog.container.fadeIn(350, function () {
                    dialog.data.slideDown(350);
                });
            });
        },

        onClose: function (dialog) {
            dialog.data.slideUp(350, function () {
                dialog.container.fadeOut(350, function () {
                    dialog.overlay.fadeOut(350, function () {
                        $.modal.close();
                    });
                });
            });
        }
    });
}

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

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

发布评论

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

评论(1

羅雙樹 2024-10-17 00:28:40

我可能是错的,但我认为问题出在您使用 delay() 上。

以下对我有用:

$('#member_ban_forum').ajaxForm( { 
    data: { member: member },
    beforeSubmit: function() { 
        $.modal.close();
    },
    success: function (responseText) {
        setTimeout(function () {
            simpleModal(responseText);
        }, 5000);
    }
});

I could be wrong, but I think the problem is with your use of delay().

The following works for me:

$('#member_ban_forum').ajaxForm( { 
    data: { member: member },
    beforeSubmit: function() { 
        $.modal.close();
    },
    success: function (responseText) {
        setTimeout(function () {
            simpleModal(responseText);
        }, 5000);
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文