jQuery 显示对话框模态动画在背景变暗时发生
这是我忍受太久的烦恼,最终决定寻求答案。我在我的 Web 应用程序中显示了一个模态 jQuery 对话框,但显示它的动画未按正确的顺序出现。我将单击事件(使用 jQuery)设置为页面上的链接,当用户单击它时,它会创建一个新的对话框,并将 autoOpen 设置为 true。从对话框中取消会销毁它,以便用户可以在下次单击时再次打开它。
无论我使用什么动画(当前使用“盲”),似乎整个页面首先变暗,然后打开对话框(仍然变暗),一旦对话框完全打开,它就会取消变暗。只是没有按正确的顺序发生。有其他人看到过这种情况,或者知道为什么会发生这种情况吗?我用来创建对话框的代码如下:
function setDialogWindows($dialogDiv, $leftList, $rightList, leftArray, rightArray, $htmlItemList) {
$dialogDiv.dialog({
autoOpen: true,
modal: true,
show: 'blind',
hide: 'blind',
width: 600,
resizable: false,
buttons: {
Cancel: function() {
resetDialog($leftList, $rightList);
$(this).dialog('destroy');
},
'Save': function() {
if (saveDialog($leftList, $rightList, leftArray, rightArray, $htmlItemList)) {
showHideItemList("show");
}
else
showHideItemList("hide");
$(this).dialog('destroy');
}
}
});
}
任何帮助将不胜感激。谢谢。
This is an annoyance that I've tolerated for too long, and finally decided to pursue an answer. I am showing a modal jQuery dialog box in my web app, but the animation to show it doesn't occur in the right order. I'm setting a click event (using jQuery) to a link on a page, and when the user clicks it, it creates a new Dialog, with autoOpen set to true. Cancel from the dialog destroys it so that the user can open it again on the next click.
No matter what animation I use (currently using "blind"), it seems like the whole page dims first, then opens the dialog box (still dimmed), and once the dialog box has completely opened, it undims it. Just not happening in the right order. Has anyone else seen this, or know why this might be happening? Code I'm using to create dialog is below:
function setDialogWindows($dialogDiv, $leftList, $rightList, leftArray, rightArray, $htmlItemList) {
$dialogDiv.dialog({
autoOpen: true,
modal: true,
show: 'blind',
hide: 'blind',
width: 600,
resizable: false,
buttons: {
Cancel: function() {
resetDialog($leftList, $rightList);
$(this).dialog('destroy');
},
'Save': function() {
if (saveDialog($leftList, $rightList, leftArray, rightArray, $htmlItemList)) {
showHideItemList("show");
}
else
showHideItemList("hide");
$(this).dialog('destroy');
}
}
});
}
Any help would be appreciated. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够让它在 IE 和 FireFox 中正确显示,其中页面变暗并且对话框动画正确完成(非变暗)。您是否有任何其他 jQuery 脚本可以作用于该
标记?
编辑:我刚刚能够重现这个问题。这似乎是对话框与动画相结合的初始显示的问题。在你的情况下,因为你不断地创建/销毁对话框,所以每次都会出现。您可能想尝试以下操作:
I was able to get this to display correctly within IE and FireFox where the page was dimmed and the dialog animation completed correctly (non-dimmed). Do you have any other jQuery script that's acting on that
<div>
tag?EDIT: I was just able to recreate this issue. It would seem that it's an issue with the initial displaying of the dialog box combined with an animation. In your case, because your constantly creating/destroying the dialog this would appear every time. Here's something you might want to try: