Textarea does not resize with the size of the value returned from the server

Asked

Viewed 35 times

-2

I configured a textarea to resize the size as the user type but when the value comes from the server the field is only the size of a line. How do you fix this?

  • Post a piece of your code so we can help you better.

  • Where it is being saved, what is the maximum size of the text?

  • $(".textarea-auto"). keyup(me.autoResize); this.autoResize = Function() { objTextArea = $(this); this.style.cssText = 'height:' + this.scrollHeight + 'px'; };

  • Now how do I for a field that will be filled by a value returned from the server?

1 answer

0


Follow the solution for whoever needs it:

    var me = this;

    this.onload = function () {
        me.bind();
    };

    this.bind = function () {
        $(".textarea-auto").keydown(me.autoResize);
        $('load', me.autoResizeLoad);
    };

    this.autoResize = function () {
        objTextArea = $(this);
        this.style.cssText = 'auto';
        this.style.cssText = 'height:' + this.scrollHeight + 'px';
    };

    this.autoResizeLoad = function () {
        var objTextArea = $('.textarea-auto');
        for (var i = 0, inb = objTextArea.length; i < inb; i++) {
                objTextArea[i].style.cssText = 'auto';
                objTextArea[i].style.cssText = 'height:' + objTextArea[i].scrollHeight + 'px';
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.