1

截图:http ://d.pr/i/A4Kv

这是我的对话代码:

function popupbox(title,html,buttonTxt,buttonAction) {
  var buttons = {};
  if(buttonTxt != null) {
    buttons[buttonTxt] = buttonAction;
  }
  buttons['Cancel'] = function() {
    jQuery(this).dialog('destroy').remove();
  };
  var p = jQuery('<form class="dialoginnerbox">' + html  + '</form>');
  p.dialog({
    autoOpen: false,
    resizable: false,
    modal: false,
    width: 'auto',
    height: 'auto',
    maxHeight: 600,
    maxWidth: 980,
    title: title,
    close: function(event, ui){
        jQuery(this).dialog('destroy').remove();
    },
    buttons: buttons
  });
  p.dialog('open');
}

有任何想法吗?

- - 更新 - -

我将返回的 html 换成了一些虚拟文本并修复了它.. 所以被放入弹出窗口的 html 的东西使它打开了两次......

4

5 回答 5

4

格式错误的 html 和内联脚本标签会导致 jquery ui 对话框打开多个对话框。

于 2012-05-22T00:38:33.937 回答
1

使用 jQueryUI 对话框;在某些情况下,jQuery 可能会将有效的 html 视为格式错误的 html。我这么说的原因是我用有效的 html 和有效的 html 注释为我的对话框加载了 html。我得到了双对话框,直到我从 ajax 加载的 html 中删除了 html 注释。例子...

内容.htm

<div id="myDialogContent">Alert!</div><!-- Here is an innocent looking comment -->

对话框.js

$.get( '/content.htm', function( html ){ 
    $( html ).dialog(); 
});

这将产生一个双重对话。如果 html 以 html 注释开头或结尾,则会出现相同的对话框问题。唯一的方法是删除 html 注释或将 html 文本包装在另一个 html 标记中,就像这样......

对话框.js

$.get( '/content.htm', function( html ){ 
    $( '<div>'+html+'</div>' ).dialog(); 
});

这将产生一个对话框。

于 2012-07-20T15:31:19.343 回答
1

函数 display_dialog() { if($('.dialog_wrapper').length) { return; }

$('<div class="dialog_wrapper"</div>').dialog({
    autoOpen: true,
    modal: true,
于 2013-12-23T15:21:10.710 回答
0

此问题的解决方法是使用计数器:

var count = 0;
var $dialog = $('<div></div>') .dialog({ ...

autoOpen: false,
                        modal: true,
                        height: 625,
                        width: 500,
                        title: pagetitle
...
});

if (count > 0) {
                        $dialog.dialog("destroy").remove();
                        count = 0;
                    }
                    $dialog.dialog('open');
                    count++;

为我工作......对于对话问题,但我在服务器上收到多个请求......类似的事情:当我第一次点击链接时,它会将信息发送到服务器。当我第二次单击(不刷新浏览器)时,它会发送两次相同的信息。当我第三次点击时,向服务器发送了三个请求,依此类推……

于 2013-04-18T22:26:40.853 回答
0

如果您将 html 包装在单个标签中,它可能会清理它。除非上面有一层,否则在 html 中包含 div 可能会导致每个 div 出现一个对话框:

这对我不起作用:

<hr /> blah blah blah 
<h3>blahblahtitle</h3> 
<div id=somestufffirst>here's the stuff</div> 
<div id=someotherstuff>here's some more stuff</div>

但这确实:

<div>
<hr /> blah blah blah 
<h3>blahblahtitle</h3> 
<div id=somestufffirst>here's the stuff</div> 
<div id=someotherstuff>here's some more stuff</div>
</div>
于 2015-07-26T17:30:30.713 回答