I have a JQuery dialog that I use to show a message to the user. The dialog have 2 buttons: "Ok" and "Details". The idea is to show a user friendly message when the dialog opens and when the user clicks the "Details" button I want to show the user friendly message plus a more detailed message under the user friendly message. The "Details" button uses the toggle function to show/hide the detailed message.

我有一个JQuery对话框,用于向用户显示消息。该对话框有2个按钮:“Ok”和“Details”。这个想法是在对话框打开时显示用户友好的消息,当用户点击“详细信息”按钮时,我希望在用户友好消息下显示用户友好消息和更详细的消息。 “详细信息”按钮使用切换功能显示/隐藏详细消息。

The dialog is defined like this:

对话框的定义如下:

function showNewDocumentDialog(dialogTitle, dialogMessage, dialogDetailMessage) {
            var dialog$ = $('#dialogId');
            var dialogDetail$ = $('#dialogDetailId')
            var showDetailContent = false;            

            dialog$.dialog({
                autoOpen: false,
                title: dialogTitle,
                modal: true,
                width: 'auto',
                height: 'auto',
                zIndex: 39000,
                open: function (type, data) {
                    $('#dialogContentId').text(dialogMessage);
                    $('#dialogDetailContentId').text(dialogDetailMessage);
                    $(this).parent().appendTo($('form:first'));

                },
                buttons: [
                                {
                                    text: "Ok",
                                    click: function () { $(this).dialog("close"); }
                                },
                                {
                                    text: "Details",
                                    click: function () {
                                        dialogDetail$.toggle(showDetailContent);
                                        showDetailContent = !showDetailContent;
                                    }
                                }
                            ]
            });

            if (dialogDetailMessage == '') {
                $(":button:contains('Details)").attr("disabled", "disabled").addClass('ui-state-disabled');
            }
            dialog$.dialog('open');
        }
    </script>   
    <div id="dialogId" title="Title" style="display: none">        
        <p id="dialogContentId">Content</p>
        <div id="dialogDetailId" style="display: none">
            <p id="dialogDetailContentId">DetailContent</p>        
        </div>
    </div>

How can I resize the dialog to fit both the user friendly message and the detailed message when the user clicks on the "Details" button? And shrink the dialog size again when the user clicks on the "Details" button to hide the detailed message?

当用户单击“详细信息”按钮时,如何调整对话框大小以适应用户友好消息和详细消息?当用户点击“详细信息”按钮隐藏详细消息时,再次缩小对话框大小?

1 个解决方案

#1


2

try to resize the overlay on details button click as follows by getting the width of the div which is made dailog

尝试通过获取dailog的div的宽度来调整详细信息按钮上的重叠按钮,如下所示

var width = $("selector").width();
var height = $("selector").height();

    if (width > 450) {
        $(".ui-widget-content").css("width", width);

    }
 if (height > 450) {
        $(".ui-widget-content").css("height", height);

    }

    $("#dvNotesPopup").dialog('option', 'position', 'center'); 
}

更多相关文章

  1. Jquery - 表单验证,为错误消息添加css样式
  2. HTML5 windows和iframe之间传递消息
  3. Struts消息国际化及异常处理
  4. 尽管“SQL语法错误”消息仍然成功执行
  5. 利用ApnsPHP包向IOS推送消息
  6. PHP结合memcacheq消息队列解决并发问题
  7. 如何使用php和mysql处理加密的私人消息
  8. 具有线程/回复的私人消息系统
  9. Oracle相当于MySQL代码“插入虚拟”以返回错误消息

随机推荐

  1. JavaScript:使用函数参数检索javascript对
  2. 入职必备技能(三)HTML、CSS、JAVASCRIPT
  3. Javascript 排序算法(转)
  4. AngularJS我在哪里可以访问加载的控制器
  5. 动画在画布中移动图像
  6. 掌握JavaScript中的事件监听
  7. JavaScript中的对象描述符
  8. 在JavaScript中访问PHP变量[重复]
  9. JQuery Image滑块从json加载图片
  10. 如何在sap.m.Datepicker中设置与上一行相