删除项目时刷新jquery.masonry

Fre*_*man 4 jquery jquery-masonry

如何通过Ajax删除项目时刷新Masonry?这是我用来删除项目的代码:

if($deletes = $('a[rel=delete]')) {
    $deletes.click(function() {
        if(!window.confirm('Are you sure you wish to delete this picture?'))
            return false;
        $t = $(this);
        $.post(
            $t.attr('href'),
            {},
            function(data) {
                if(data == "success")
                    $t.parents('.deleteable:first').fadeOut();
            }
        );
        return false;           
    });
}
Run Code Online (Sandbox Code Playgroud)

我想要刷新的原因是在删除项目后消除结果空格.

Joh*_*ess 5

添加一个回调给你fadeOut()实际调用.remove()已删除的元素一旦淡出,然后.masonry()再次调用容器.