问题描述:

By default all text area are given a fixed height in main css file.I have created a jHTMLArea control and when user provide a huge value, we need to display the entire content by resizing the JHTML iframe.Currently the below code gives user the option to resize and view the data but I want the entire jHTMLtext area to auto resize based on content height. Kindly help.

 $(document).ready(function () {

$(".txtContentDesc").htmlarea({

loaded: function () {

this.iframe[0].contentWindow.focus();

var elemId = $(this.textarea).attr("id");

$(this.editor).blur(function (event) {

return captureJHtmlContentTextareaonchange(elemId);

});

}

}).parent().resizable({ alsoResize: $('.jHtmlArea ').find('iframe') });

});

网友答案:

Here, I am taking the height of contents inside iframe and updating it on loading the jHTMLArea.

  $(".txtContentDesc").htmlarea({

        loaded: function () {

            var elemId = $(this.textarea).attr("id");              
            var height = $("#" + elemId + "").prev().find('iframe').contents().height();
            $("#" + elemId + "").prev().css("height", height + "px");            
            $("#" + elemId + "").prev().find('iframe').css("height", height + "px");
            $("#" + elemId + "").prev().find('iframe').height(height);
            $(this.editor).mouseleave(function (event) {
                return captureJHtmlContentTextareaonchange(elemId);
            })

        }
    });
相关阅读:
Top