JQuery live event binding prevents additional callbacks
- by Alex Ciminian
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