【问题标题】:why does jquery dialog() auto height, width fail?为什么jquery dialog()自动高度,宽度失败?
【发布时间】:2013-05-06 08:37:01
【问题描述】:

我正在使用一些 jquery 弹出对话框

 var div = $('#mditem_temp');
 var dlg = $(div).html(data).dialog({
                        height: 'auto',
                        width: 'auto',
                        modal: true,
                        show: "drop",
                        hide: "fold",
                        position: "top",
                        autoResize:true,
                        close: function (event, ui) {
                            $("#mditem_temp").dialog('close');
                        },
                        buttons: {
                            'Add': function (d) {
                                pqr();

                                $(this).dialog('close');
                                $("#mditem_temp").dialog('close');

                            }
                        }
                    }).dialog('open');

并且要写入的数据是局部视图,但弹出窗口不会随数据调整高度宽度。可能是什么原因?

【问题讨论】:

  • 数据是什么样的?它是固定的元素(img,iframe)吗?

标签: jquery jquery-ui jquery-ui-dialog


【解决方案1】:

这通常是由数据变量中的固定高度/宽度或显示问题引起的。在 Firebug 或类似工具中检查渲染的部分,看看它是否在对话框包含的区域之外渲染。如果不是,那么它是导致问题的数据 html 的大小。

当然,另一种选择是在每次打开时动态设置对话框的高度:

$(div).html(data).dialog({
  ...
  open: function(){
    var height = [calculate height with JS];
    $(this).height(height);
  }
});

【讨论】:

    猜你喜欢
    • 2017-08-25
    • 2014-07-05
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    • 2011-03-11
    • 2019-07-31
    • 1970-01-01
    • 2013-02-07
    相关资源
    最近更新 更多