Search code examples
jqueryfadeout

jQuery function doesn't work after .load


Possible Duplicate:
jQuery events not happening after AJAX load?

I've got function which re-load page after clicking a button, here it is:

$(".updated").load("index.php .updated");

It loads everything perfectly. But after loading other function which should fadeout table row - doesn't work. Here is the function:

$('.deletetable').click(function () {
 var x = this.id;
 $.post("Changes.php", { ID: x, CLEAR: '1'});
 $('#slideup'+x).fadeOut("slow");

It works fine aswell, but before .load happens.

Any ideas?

Thank you!


Solution

  • Use this:

    $(document).on('click', '.deletetable', function () {
        var x = this.id;
        $.post("Changes.php", {
            ID: x,
            CLEAR: '1'
        });
        $('#slideup' + x).fadeOut("slow");
    });