jQuery plugin: ‘autoResize’ – James Padolsey

Inspired by Jason Frame’s method, I’ve cre­ated an ani­mat­ing ‘autoRe­size’ jQuery plu­gin. Although it was inspired by his plu­gin it has a few slight dif­fer­ences, most notably the way in which the off-screen “test­ing” takes place. In his plu­gin (appar­ently inspired by Facebook’s imple­men­ta­tion) a DIV is cre­ated off-screen and is filled with the textarea’s value when­ever it changes. The height of this DIV is retrieved and then applied to the textarea. My plu­gin makes use of the scroll­Top DOM prop­erty to gain the true height of the text and then applies that directly (or via ani­ma­tion) to the textarea.

via jQuery plu­gin: ‘autoRe­size’ – James Padolsey. Extremely nice jQuery plu­gin for auto-resizing textar­eas. The one issue is that on page load the plu­gin doesn’t cal­cu­late the size of the textarea. Read­ing the jQuery API docs for the Ready event it looks like a nor­mal jQuery object can not be binded to ready, only the jQuery doc­u­ment core object can be.

Comments are disabled for this post