Reputation: 3228
I'm using the autosize
plugin (but wouldn't mind alternatives) and I need to resize the textarea
I have on its load, and it should also automatically resize as you type (like what autosize.js
allows you to do).
My question is, does autosize
come with this option out of the box? I didn't find such info on its webpage and I tried both $(el).trigger('autosize.resize')
and autosize.update($(el))
after my text areas are loaded and neither worked.
Also, my textareas are original hidden, which will be toggled show with a CSS class. I wonder if that's hindering the process.
Any ideas is appreciated, thanks!
Upvotes: 0
Views: 339
Reputation: 4443
With a display: none
you can't calculate anything because the height & width of the textarea is 0x0px.
You must update the size after textarea has been shown. Edit : or toggle it shown first then apply autosize.
Upvotes: 1
Reputation: 1768
Could you use CSS to size the textarea
appropriately on initial load, and then let the autosize
script handle resizing the textarea
as the content is changed?
Upvotes: 0
Reputation: 34150
I tried different plugins and even wrote a plugin myself but none of them were good. I ended up using a div with contenteditable="true"
This worked perfectly for me.
Upvotes: 0