$(document).ready(function() {
  $('a.close').click(function(event){
    event.preventDefault();
    $(this).parent().slideUp(250);
  });

  // Spree locates hidden with prev(), which with our current version of jQuery
  // does not locate the hidden field, resulting in the delete failing. This
  // handler updates the hidden field, fixing the problem.
  $('body').on('click', 'a.remove_fields', function() {
    $(this).next("input[type=hidden]").val("1");
    return false;
  });
});
