简单模式-当另一个模式存在时调用模式?

发布于 2024-11-04 07:55:09 字数 1030 浏览 0 评论 0原文

我正在使用 Simple Modal,除了一件事之外,我让它工作得很好。

我无法弄清楚如何处理模式已经可见并且调用另一个模式的情况。

我想要的是像 Shadowbox 这样的东西,它会将框的大小调整为新内容的大小。 尽管如果不可能的话,我会接受盒子消失并出现新盒子的情况。

我该怎么做?

这是我当前的代码

//show/hide animations
$.extend($.modal.defaults, {
    onOpen: function (dialog) {
        dialog.overlay.fadeIn('fast', function () {
            dialog.data.show();
            dialog.container.show('slide', {direction: 'down'}, 'medium');
        });
    },
    onClose: function (dialog) {
        dialog.container.hide('slide', {direction: 'up'}, 'medium', function () {
            dialog.overlay.fadeOut('fast', function () {
                $.modal.close();
            });
        });
    }
});

//triggers 
$('#subscribe_form').modal({
  minWidth: 860,
  minHeight: 390
});

//this link is both inside the subscribe_form modal, and on a menu bar
$('.login_link').live('click', function() {
  $('#login_dialog').modal();
});

I am using Simple Modal and I have it working perfectly except for one thing.

I can't work out how to handle cases where the modal is already visible and another modal is called.

What I want is something like shadowbox where it will resize the box to the size of the new content.
Although if not possible I will settle with the box disappearing and the new one appearing.

How would I do this?

This is my current code

//show/hide animations
$.extend($.modal.defaults, {
    onOpen: function (dialog) {
        dialog.overlay.fadeIn('fast', function () {
            dialog.data.show();
            dialog.container.show('slide', {direction: 'down'}, 'medium');
        });
    },
    onClose: function (dialog) {
        dialog.container.hide('slide', {direction: 'up'}, 'medium', function () {
            dialog.overlay.fadeOut('fast', function () {
                $.modal.close();
            });
        });
    }
});

//triggers 
$('#subscribe_form').modal({
  minWidth: 860,
  minHeight: 390
});

//this link is both inside the subscribe_form modal, and on a menu bar
$('.login_link').live('click', function() {
  $('#login_dialog').modal();
});

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

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

发布评论

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

评论(2

不弃不离 2024-11-11 07:55:09

这似乎不是最好的解决方案,但您可以尝试:

http://jsfiddle.net/Xwn3G/

$('.login_link').live('click', function() {
    setTimeout(function(){$('#login_dialog').modal();}, 1500);
    $.modal.close();
});

据我所知,对显示新模式的调用必须在模型关闭完成之后进行;或者,它取消模型 html 中元素的 onClose 事件。我还能够让它在 1000 毫秒内运行,但这可能取决于用户的浏览器。

This doesn't seem like the greatest solution, but you could try:

http://jsfiddle.net/Xwn3G/

$('.login_link').live('click', function() {
    setTimeout(function(){$('#login_dialog').modal();}, 1500);
    $.modal.close();
});

From what I can tell, the call to the show the new modal has to follow the completion of the model close; or, it's canceling the events of the elements within the model html onClose. I was also able to get it to work with 1000 milliseconds, but that will probably depend on the user's browser.

悲凉≈ 2024-11-11 07:55:09

您可以通过假 get 调用来执行此操作,

$('.login_link').live('click', function() {
    $.get('', function(){
        $('#login_dialog').modal();
    });
});

这样模态函数将在回调中被调用并且可以工作。我不确定为什么这在不超出当前范围的情况下不起作用,但至少有效:)

You could do this doing a fake get call

$('.login_link').live('click', function() {
    $.get('', function(){
        $('#login_dialog').modal();
    });
});

That way the modal function will be called on the callback and would work. I am not sure the reasons why this doesn't work without getting out of the current scope but at least works :)

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