PDA

View Full Version : Jquery with dynamically added forms



levani
03-28-2011, 07:55 PM
I use jquery appendTo function to add new textarea forms dynamically and I also use jquery autoResize plugin to automatically change the height of the textarea while typing. Here is the code:


$('textarea.text').autoResize({limit : 300});

The problem is that the auto resize doesn't work with dynamically added forms! It works fine with other inline forms... Can anyone please tell what is the problem?

devnull69
03-28-2011, 08:09 PM
Did you call .autoResize() before or after the forms have been added dynamically?

levani
03-28-2011, 09:28 PM
I call it once on page load...


$(document).ready(function() {
$('textarea.text').autoResize({limit : 300});
});

devnull69
03-28-2011, 09:44 PM
You'll have to call it (again) after the additional elements have been added. Otherwise autoResize can not know anything about them.