【问题标题】:jquery dialog needs to click twice to closejquery 对话框需要点击两次才能关闭
【发布时间】:2017-01-06 07:18:42
【问题描述】:

我一直在尝试设置一个 div 以使用 jquery 对话框弹出

首先,当用户单击按钮并打开对话框时,当他关闭对话框时,它会在第一次单击时关闭。

当他第二次尝试关闭对话框时,它会再次打开相同的弹出窗口,他需要再次单击关闭按钮才能将其关闭。

https://jsfiddle.net/xwpwku1w/31/

jQuery:

function ShowMyContainerDivForSC(containerID, title, width, height) {
     if ($(containerID).data('uiDialog'))
         $(containerID).dialog('destroy');
     $(containerID).dialog({
         width: width,
         draggable: true,
         height: height,
         resizable: false,
         title: title,
         modal: false,
         open: function (event, ui) {
             $(this).show();
         },
         close: function (event) {
             if (typeof AfterClose == "function") {
                 AfterClose(containerID);
             }
             //$(this).remove();-- commented cause it just removes the element.
         }
     });
     return false; 
}

【问题讨论】:

  • 你能创建一个 jsfiddle 吗?
  • 你是从哪里复制粘贴的? >
  • 从这里,我尝试添加 jquery。但不工作 - jsfiddle.net/AvF8V
  • 您在问题中添加的jsfiddle 似乎没有任何弹出对话框。

标签: javascript jquery jquery-ui-dialog


【解决方案1】:

修改了您的代码,var containerID = "#mpopup"; 现在对我来说可以正常工作https://jsfiddle.net/xwpwku1w/33 请检查。

旁注 - 建议您将 $(containerID) 保存在一个变量中,因为它使用了 3 次,https://jsfiddle.net/xwpwku1w/34

【讨论】:

    猜你喜欢
    • 2013-06-03
    • 2021-07-19
    • 2020-12-07
    • 1970-01-01
    • 2011-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-08
    相关资源
    最近更新 更多