jQuery UI对话框搞砸了

时间:2022-10-08 23:30:18

I have several dialog boxes in a website I built for a client. When two dialogs are open at the same time, things eventually get messed up. The dialog seems to be looking good the first time it shows up. But then when the user closes the dialog (the one on top) and opens it again, it gets messed up. (check the images)

我在为客户建立的网站中有几个对话框。当两个对话框同时打开时,事情最终会搞砸。第一次出现时,对话框看起来很好看。但是当用户关闭对话框(顶部的那个)并再次打开它时,它就会搞砸了。 (查看图片)

What I'm basically doing is the following:

我基本上做的是以下内容:

$(document).ready(function() {
   $("#someDiv").dialog({
      //options
   });

   $("#someButton").click(function() {
      $("#someDiv").dialog('open');
   });

   $("#closeButton").click(function() {
      $("#someDiv").dialog('close');
   });
});

That's basically the flow of how I open and close the dialogs. Am I doing anything wrong?

这基本上就是我打开和关闭对话框的流程。我做错了吗?

When the user opens the dialog for the first time: http://i43.tinypic.com/2dt9fk7.png

当用户第一次打开对话框时:http://i43.tinypic.com/2dt9fk7.png

When the user opens the dialog again: http://i40.tinypic.com/v6sqq9.png

当用户再次打开对话框时:http://i40.tinypic.com/v6sqq9.png

1 个解决方案

#1


1  

I mostly agree with cambraca; however, here's another thought to add to the "It's CSS" point:

我大多赞同cambraca;然而,这是另一个想法添加到“它的CSS”点:

When the dialog gets closed, jQuery UI doesn't seem to move it back to its original place in the DOM tree. It seems to get moved to just before the </body> closing tag. So for consistency, change your markup so that it STARTS there as well, thereby avoiding possible CSS style inheritance issues.

当对话框关闭时,jQuery UI似乎不会将其移回DOM树中的原始位置。它似乎被移动到 结束标记之前。因此,为了保持一致性,请更改您的标记,以便它在那里开始,从而避免可能的CSS样式继承问题。

#1


1  

I mostly agree with cambraca; however, here's another thought to add to the "It's CSS" point:

我大多赞同cambraca;然而,这是另一个想法添加到“它的CSS”点:

When the dialog gets closed, jQuery UI doesn't seem to move it back to its original place in the DOM tree. It seems to get moved to just before the </body> closing tag. So for consistency, change your markup so that it STARTS there as well, thereby avoiding possible CSS style inheritance issues.

当对话框关闭时,jQuery UI似乎不会将其移回DOM树中的原始位置。它似乎被移动到 结束标记之前。因此,为了保持一致性,请更改您的标记,以便它在那里开始,从而避免可能的CSS样式继承问题。