I use this function to autosize textarea:
$('textarea').each(function () {
this.setAttribute('style', 'height:' + (this.scrollHeight) + 'px;overflow-y:hidden;');
}).on('input', function () {
this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px';
});
I have this workflow: user goes to page A
, fills textarea and saves it, then he closes page A
and visit it again, textarea resizes only on input
, but I need to resize it every time as user visits this page.