How do I refresh Masonry when an item is deleted via Ajax? This is the code I'm using to delete the item:
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;
});
}
The reason I want a refresh is to eliminate the resulting spaces after items are deleted.
Add a callback to your fadeOut()
to actually call .remove()
your deleted element once it's faded out, then just call .masonry()
on the container again.