app/views/spree/favorite_products/destroy.js.erb
<% if @success %>
if($('.favorite_link').length) {
$('.favorite_link').attr('href', '<%= favorite_products_path(:id => params[:id], type: params[:type]) %>').attr('id', 'mark_as_favorite').data('method', 'post').text('<%= Spree.t(:mark_as_favorite) %>')
alert('Successfully unmarked as favorite');
} else {
<% if @favorite.favoritable_type == 'Spree::Product' %>
$("#favorite_product_<%= @favorite.favoritable_id%>").remove();
<% else %>
$("#favorite_variant_<%= @favorite.favoritable_id%>").remove();
<% end %>
alert("Successfully removed favorite product from your list");
if (!$('.favorite_product').length) {
window.location = '<%= favorite_products_path %>'
}
}
<% else %>
alert("Could not remove product form your list")
<% end %>