Search code examples
jqueryliveautoresize

jQuery autoresize with live


How can I use the jquery plugin "autoresize" with JQuery's live() function best? The problem is, that the plugin creates an textarea behind the current one (with position absolute). When I use the jquery live() function I get stuck in an infinite loop, because the textarea, created by the script, gets another one and so on... Hope that you can follow me.

How can I use live() with that plugin?


Solution

  • In autoresize.jquery.js, as you said, it creates a clone of the textarea to perform text size calculations. Here it is:

    return textarea.clone().removeAttr('id').removeAttr('name').css({
    

    As you see it strips name and id attributes. You could modify this line to add a class attribute which you can then filter out with your $.live() selector. E.g.

    return textarea.clone().removeAttr('id').removeAttr('name').addClass('clone').css({
    

    And

    $('textarea:not(.clone)').live()