Jquery对话框显示:盲目,隐藏:下降;只工作一次

发布于 2024-11-30 05:48:28 字数 803 浏览 0 评论 0原文

我有以下代码:

$("#dialog").dialog({
    height: 360,
    width: 630,
    modal: true,
    autoOpen: false,
    show: 'blind',
    hide: 'drop',
    resizable: false,
    dialogClass: 'noFloat'
});

$("#openDiag").click(function() {

    $("#dialog").dialog('open');

    $.ajax({
        type: "POST",
        url: "setHsdSegment.jsp",
        dataType: "html",
        resizable: false,
        //data:"name="+name+"&age="+age,
        success: function(data) {
            $("#response").html(data);
        }
    });
});

我面临的问题是,显示和隐藏只能工作一次。如果我再次单击按钮(#openDialog),则仅显示半透明屏幕,而不显示对话框。

有趣的是,只有当 hide 为“drop”且 show 为除“drop”之外的任何其他内容时,才会发生这种情况。但是当显示是“下降”并且隐藏是其他任何内容时,那么一切都很好。

当隐藏“drop”时,显示是否必须“drop”?

编辑:这只发生在 IE 中。 (像往常一样,IE 引起了问题。:D...为什么?)

I have the following code:

$("#dialog").dialog({
    height: 360,
    width: 630,
    modal: true,
    autoOpen: false,
    show: 'blind',
    hide: 'drop',
    resizable: false,
    dialogClass: 'noFloat'
});

$("#openDiag").click(function() {

    $("#dialog").dialog('open');

    $.ajax({
        type: "POST",
        url: "setHsdSegment.jsp",
        dataType: "html",
        resizable: false,
        //data:"name="+name+"&age="+age,
        success: function(data) {
            $("#response").html(data);
        }
    });
});

The problem that I am facing is, the show and hide works only once. If I click on the button (#openDialog) again, only the translucent screen shows up and not the dialog box.

The funny thing is, this happens only when the hide is 'drop' and show is anything else except the 'drop'. But when the show is 'drop' and hide is anything else, then everything is fine.

Does the show have to be 'drop' when the hide is 'drop'?

EDIT: This is happening only in IE. ( as usual IE is causing problem. :D... why?)

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

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

发布评论

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

评论(3

陈年往事 2024-12-07 05:48:29

这是 jQuery UI 中的一个已知错误:
http://bugs.jqueryui.com/ticket/5615

快速修复方法是销毁并重新创建对话框:

var $dlg = $("#dialog");
var dlgOptions = $dlg.dialog("option");
$dlg.dialog("destroy");
$dlg.dialog(dlgOptions);

看起来对话框会离开屏幕,并且在下次显示时忘记返回(除非“show”设置为“drop”,效果恰恰相反)。

It is a known bug in jQuery UI:
http://bugs.jqueryui.com/ticket/5615

A quick fix is to destroy and recreate the dialog:

var $dlg = $("#dialog");
var dlgOptions = $dlg.dialog("option");
$dlg.dialog("destroy");
$dlg.dialog(dlgOptions);

It seams that the dialog goes out of the screen and forgets to come back the next time it's shown (unless "show" is set to "drop" which does the exact opposite).

半窗疏影 2024-12-07 05:48:29

在这个演示中似乎工作正常: http://jsfiddle.net/william/mQkH7/

也许尝试升级/降级您的 jQuery UI。

It seems to be working fine in this demo: http://jsfiddle.net/william/mQkH7/

Perhaps try to upgrade/downgrade your jQuery UI.

や三分注定 2024-12-07 05:48:29

我找到了解决方法。不确定这是否是最好的方法,但它确实有效。
如下:

 $("#openDiag").click(function(){
  $('#dialog').dialog('destroy');
   $("#dialog").dialog({
                    height: 360,
                    width: 630,
                    modal: true,
                    autoOpen: true,
                    show: 'slide',
                    hide: 'drop',
                    resizable: false,
                    dialogClass: 'noFloat',
                    buttons: { "Ok": function() { $(this).dialog("close"); 

                                                } }
                });

似乎对于 IE,我需要先销毁对话框插件,然后才能创建新的对话框插件。我一开始就保留了“破坏”,因为我想保持结束效果。我在这里缺少的是在销毁插件之前检查插件是否存在。但它仍然可以正常工作,没有错误;我不知道为什么。

但这仍然没有回答问题,为什么这个问题首先存在,只针对这个特定的组合并且只在 IE 中。有人能告诉我原因吗?

I found a work around for it. Not sure if this is the best way, but it works.
It is as follows:

 $("#openDiag").click(function(){
  $('#dialog').dialog('destroy');
   $("#dialog").dialog({
                    height: 360,
                    width: 630,
                    modal: true,
                    autoOpen: true,
                    show: 'slide',
                    hide: 'drop',
                    resizable: false,
                    dialogClass: 'noFloat',
                    buttons: { "Ok": function() { $(this).dialog("close"); 

                                                } }
                });

It seems like for IE, I need to destroy the dialog plugin before I create a new one. I kept the 'destroy' at the beginning because I wanted to maintain the closing effect. What I am missing here is to check if the plugin exists, before I destroy it. But it still works with no errors; that I don't know why.

But this still doesn't answer the question, why the problem existed in the first place, only for this particular combination and only in IE. Could someone tell me the reason?

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