简单模式-当另一个模式存在时调用模式?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎不是最好的解决方案,但您可以尝试:
http://jsfiddle.net/Xwn3G/
据我所知,对显示新模式的调用必须在模型关闭完成之后进行;或者,它取消模型 html 中元素的 onClose 事件。我还能够让它在 1000 毫秒内运行,但这可能取决于用户的浏览器。
This doesn't seem like the greatest solution, but you could try:
http://jsfiddle.net/Xwn3G/
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.
您可以通过假 get 调用来执行此操作,
这样模态函数将在回调中被调用并且可以工作。我不确定为什么这在不超出当前范围的情况下不起作用,但至少有效:)
You could do this doing a fake get call
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 :)