<script>
$(".fa-remove").click(function(){
  var file = $(this).closest("a").data("file");
  $("#file-to-remove").html(file);
});

$("#delete-file").click(function() {
  $.ajax({
    type: "POST",
    url: "{{ url('admin/deleteFile') }}",
    dataType: "json",
    data: {
      file: $("#file-to-remove").html()
    }
  }).done(function(data) {
    window.location.href = "{{ url('admin/media') }}";
  }).error(function(x, t, m) {
		printAjaxError(x, t, m);
  });
});
</script>
