Make JQuery UI Dialog automatically grow HEIGHT to fit its contents (width remains static)

后端 未结 4 1876
名媛妹妹
名媛妹妹 2021-02-08 00:12

Having looked into Make JQuery UI Dialog automatically grow or shrink to fit its contents, I am using the height: \"auto\" option when building a jQuery modal dialo

4条回答
  •  情话喂你
    2021-02-08 00:46

    This is 4 years Late but i have the same problem.

    Wrote code that fixed it

    Put a unique class on your dialog:

    dialogClass:"someClassName"
    
    $(".someClassName").resize(function () {
        var totalHeight = 0;
        var children = $(".someClassName").children(); //get all divs inside the dialog
        for (var i = 0; i < children.length; i++) {
            if ($(children[i]).innerWidth() > 15) {
                var childrenHeight = children[i].scrollHeight;
                totalHeight += childrenHeight;//make sure your dialog will be the correct height
            }
        }
        $("#idOfContentWithWrongHeight").innerHeight($("#idOfContentWithWrongHeight")[0].scrollHeight);//put the content at the height it should appear
        $(".someClassName").height(totalHeight);//update the height of the dialog
    });
    

提交回复
热议问题