JQuery live event binding prevents additional callbacks
Posted
by Alex Ciminian
on Stack Overflow
See other posts from Stack Overflow
or by Alex Ciminian
Published on 2010-03-08T10:37:44Z
Indexed on
2010/03/08
11:21 UTC
Read the original article
Hit count: 566
Hey!
I was building an AJAX listing of elements in my site, with the ability to delete them (also via AJAX). The following piece of code handles the deletion:
$('ul.action-menu a.delete').live('click', function () {
$.post($(this).attr('href'), function (data) {
var recvData = eval( '(' + data + ')' );
if ((recvData.status == 1) && (recvData.delId)) {
$('#alert-' + recvData.delId).fadeOut();
} else {
alert(recvData.message);
}
});
return false;
});
This works just fine. The problem is that, for elements that were not there when the page was loaded (i.e. that were added dynamically), the post callback does not get executed and it doesn't fade out after being deleted (the AJAX call is being made, it just doesn't execute the callback).
Do you have any idea why this is happening?
Thanks,
Alex
© Stack Overflow or respective owner