在对话框中设置大小

本文关键字:设置 对话框 | 更新日期: 2023-09-27 18:33:47

我使用对话框,但它的大小不对,有什么办法可以改变它吗?

     <script type="text/javascript">
     $.ajaxSetup({ cache: false });
     $(document).ready(function () {
         $(".openDialog").live("click", function (e) {
             e.preventDefault();

             $("<div></div>")
                .addClass("dialog")
                .attr("id", $(this)
                .attr("data-dialog-id"))
                .appendTo("body")
                .dialog({
                    title: $(this).attr("data-dialog-title"),
                    close: function () { $(this).remove() },
                    modal: true
                })
                .load(this.href);
         });
         $(".close").live("click", function (e) {
             e.preventDefault();
             $(this).closest(".dialog").dialog("close");
         });
     });
</script>

在对话框中设置大小

在 jquery 文档中,您可以使用 widthheight

http://docs.jquery.com/UI/Dialog

对话框的高度(以像素为单位)。指定"auto"也是 支持使对话框根据其内容进行调整。

.dialog({height:

对话框的宽度(以像素为单位)。

.dialog({height:

 $.ajaxSetup({ cache: false });
 $(document).ready(function () {
     $(".openDialog").live("click", function (e) {
         e.preventDefault();

         $("<div></div>")
            .addClass("dialog")
            .attr("id", $(this)
            .attr("data-dialog-id"))
            .appendTo("body")
            .dialog({
                width:yourValueHere,//Put width
                height:yourValueHere,//Put height
                title: $(this).attr("data-dialog-title"),
                close: function () { $(this).remove() },
                modal: true
            })