How does Stackoverflow implement the resizable textarea?
Is that something they rolled themselves or is it a publicly available component that I can easily attach to textareas on my sites?
I found this question and it doesn't quite do what I want.
autosizing-textarea
That talks more about automatically resizing textareas whereas I want the little grab-area that you can drag up and down.
It can be achieved by using JavaScript and jQuery. Method 1: Using JavaScript: To change the height, a new function is created which changes the style property of the textarea. The height of the textarea is first set to auto. This value makes the browser set the height of an element automatically.
In many browsers, <textarea> elements are resizable by default. You may override this behavior with the resize property.
Resize a text box Select the text box. Select one of the handles and drag until the text box is the size you want.
What I meant was that when you create the text area in myFunction() you can add the draggable=true attribute to it and specify the relevant ondragstart and ondragend logic for those relevant areas.
StackOverflow uses a jQuery plugin to accomplish this: TextAreaResizer.
It's easy enough to verify this - just pull the JS files from the site.
Historical note: when this answer was originally written, WMD and TextAreaResizer were two separate plugins, neither one of which was authored by the SO Dev Team (see also: micahwittman's answer). Also, the JavaScript for the site was quite easy to read... None of these are strictly true anymore, but TextAreaResizer still works just fine.
I needed a similar functionality recently. Its called Autogrow and it is a Plugin of the amazing jQuery library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With