jQuery UI 对话框变得混乱

发布于 2024-12-29 12:50:22 字数 724 浏览 0 评论 0原文

我为客户构建的网站中有几个对话框。 当两个对话框同时打开时,事情最终会变得混乱。该对话框第一次出现时看起来看起来不错。但是,当用户关闭对话框(顶部的对话框)并再次打开它时,它就会变得混乱。 (检查图像)

我基本上所做的如下:

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

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

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

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

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

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

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

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

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

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

发布评论

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

评论(1

韬韬不绝 2025-01-05 12:50:22

我基本同意坎布拉卡的观点;然而,这里还有另一个想法要添加到“这是 CSS”点上:

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

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

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.

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