使用jquery创建对话框时,如何隐藏对话框div?

时间:2022-11-25 18:10:46

I am creating a dialog like in this page:

我正在创建一个类似于此页面的对话框:

http://jqueryui.com/demos/dialog/#modal-confirmation

http://jqueryui.com/demos/dialog/#modal-confirmation

(click view source)

(点击查看源)

on the bottom is the div that gets placed in the dialog. The dialog works perfect when called by the javascript but the dialog is apparent at the bottom of the page when it loads. (minus all the styling that gets applied when it is called by the javascript function)

在底部是放置在对话框中的div。当javascript调用时,该对话框非常完美,但加载时页面底部会显示对话框。 (减去javascript函数调用时应用的所有样式)

How can I hide the div and still allow the dialog to use it? I have tried setting style="visibility:hidden" but that prevents it from being shown when called by the javascript.

如何隐藏div并仍允许对话框使用它?我已经尝试设置style =“visibility:hidden”但是这会阻止它在被javascript调用时显示。

1 个解决方案

#1


31  

This may be a stupid question, but instead of "visibility:hidden" have you tried "display:none;"? I had to solve the same problem for a project I'm working on and I'm reasonably sure display:none worked.

这可能是一个愚蠢的问题,但你没有尝试“display:none;”而不是“visibility:hidden”吗?我必须为我正在进行的项目解决同样的问题,我相当肯定显示:没有工作。

You can also use the

你也可以使用

$(foo).dialog({ autoOpen: false });

option to "initialize" the dialog (thus hiding it and all that good stuff). The only catch is, you'll probably see the dialog "flicker" as the page loads but before jQuery has a chance to hide it.

“初始化”对话框的选项(从而隐藏它和所有好东西)。唯一的问题是,您可能会在页面加载时看到对话框“闪烁”,但在jQuery有机会隐藏它之前。

#1


31  

This may be a stupid question, but instead of "visibility:hidden" have you tried "display:none;"? I had to solve the same problem for a project I'm working on and I'm reasonably sure display:none worked.

这可能是一个愚蠢的问题,但你没有尝试“display:none;”而不是“visibility:hidden”吗?我必须为我正在进行的项目解决同样的问题,我相当肯定显示:没有工作。

You can also use the

你也可以使用

$(foo).dialog({ autoOpen: false });

option to "initialize" the dialog (thus hiding it and all that good stuff). The only catch is, you'll probably see the dialog "flicker" as the page loads but before jQuery has a chance to hide it.

“初始化”对话框的选项(从而隐藏它和所有好东西)。唯一的问题是,您可能会在页面加载时看到对话框“闪烁”,但在jQuery有机会隐藏它之前。