简体   繁体   English

对话框仅在第一次工作

[英]dialog works first time only

I have the following java script code 我有以下Java脚本代码

      function showDialog() {
        $("#dialog").dialog({
            autoOpen : true, height : '325', width : 'auto', modal : true, closeOnEscape : false,

        });
        $("#dialog").dialog('option', 'title', "Manage Questions");
        $("#dialog").dialog('option', 'show', 'drop');
        $("#dialog").dialog('option', 'resizable', true)
        var strHtml = <MyCode>;
        $("#dialog").html(strHtml);
        $("#dialog").html();
        $("#dialog").dialog('open');
        }

when I call showDialog first time it works fine. 当我第一次调用showDialog时,它工作正常。 but after that when user click on button that calls this function, the dialog appears then automatically disappear, if user clicks again it works fine, in other words First time it works fine, then user have to click twice to make it work. 但是之后,当用户单击调用此功能的按钮时,对话框将出现,然后自动消失,如果再次单击该对话框,它将运行良好,换句话说,第一次运行良好,则用户必须单击两次才能使其运行。

You have not added any button for closing dialog, please add below code for closing dialog first and then open it. 您尚未添加任何用于关闭对话框的按钮,请先添加以下代码以关闭对话框,然后再打开它。

 $("#dialog").dialog("close");

your code should be like below 您的代码应如下所示

function showDialog() {
        //close dialog
        $("#dialog").dialog("close");
        $("#dialog").dialog({
            autoOpen : true, height : '325', width : 'auto', modal : true, closeOnEscape : false,

        });
        $("#dialog").dialog('option', 'title', "Manage Questions");
        $("#dialog").dialog('option', 'show', 'drop');
        $("#dialog").dialog('option', 'resizable', true)
        var strHtml = <MyCode>;
        $("#dialog").html(strHtml);
        $("#dialog").html();
        $("#dialog").dialog('open');
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM