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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With