monkey blot
monkey blot

Reputation: 985

keyup not working on dynamically loaded textareas

Other event types seem to work fine here - for example, mouseenter:

$("body").delegate(".textareas", "mouseenter", myalert);

But using keyup, or keypress - it wont work. I didn't change anything else in my code except the event type on this line. Example:

$("body").delegate(".textareas", "keyup", myalert);

I type in a textarea, but now myalert doesn't get called.

I'm using jquery 1.7.1.

Upvotes: 3

Views: 1510

Answers (2)

monkey blot
monkey blot

Reputation: 985

DOMSubtreeModified does more than I need for this, but at least it seems to notice any entered text too, so if anyone else runs into this same problem, that's what's sort of working for me until a better solution is found.

Upvotes: 0

austinbv
austinbv

Reputation: 9491

You can use an on to bind

http://jsfiddle.net/Jy2rA/

$('button').click(function () {
    $('body').append('<textarea>');
});

$('body').on('keyup', 'textarea', function() {
    $('p').fadeIn(function(){$(this).fadeOut()});
});​

Upvotes: 1

Related Questions