I set up a textarea to resize the size as the user type, but when the value comes from the server the field is only one line size. How do you resolve this?
I set up a textarea to resize the size as the user type, but when the value comes from the server the field is only one line size. How do you resolve this?
Follow the solution for those who need 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';
}
}