I'm using jquery to dynamically generate textarea boxes inside of a click() event but I'd like the textareas to auto-resized but I'm having trouble getting it to fire. I'm trying to work with this example but I'm not making much progress. Here is a small sample of the area I'm having trouble with.
$(somebutton).click(function(){
    $(element).html("");
    editor=$("<textarea style=\"width:100%;\">sdf sd sds sa  sdf sad sd asd sad sad sad dasd sda s asd fasdsad</textarea>").appendTo($(element));
    $(function() {
        $(element).editor.on('input', function () {
            $(element).editor.style.height = 'auto';
            $(element).editor.style.height = ($(element).editor.scrollHeight) + 'px';
        });
    });
    $(element).editor.trigger('input');
});
Any suggestions? TY
 
    