Make JQuery UI Dialog automatically grow or shrink to fit its contents

前端 未结 7 1892
遇见更好的自我
遇见更好的自我 2020-12-04 09:28

I have a JQuery UI dialog popup that displays a form. By selecting certain options on the form new options will appear in the form causing it to grow taller. This can lead

7条回答
  •  粉色の甜心
    2020-12-04 09:29

    Height is supported to auto.

    Width is not!

    To do some sort of auto get the size of the div you are showing and then set the window with.

    In the C# code..

    TheDiv.Style["width"] = "200px";
    
        private void setWindowSize(int width, int height)
        {
            string widthScript =    "$('.dialogDiv').dialog('option', 'width', "    +   width   +");";
            string heightScript =   "$('.dialogDiv').dialog('option', 'height', "   +   height  + ");";
    
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(),
                "scriptDOWINDOWSIZE",
                "", false);
        }
    

提交回复
热议问题