view .svn/pristine/0d/0d408463a01e894d3f86946e8b5d1925b0335095.svn-base @ 1625:808a40a7cac7 live

Have a go at fixing #570 Can't delete downloadable file from version in project with no issue tracker
author Chris Cannam
date Thu, 07 Feb 2019 13:48:00 +0000
parents 261b3d9a4903
children
line wrap: on
line source
var fileSpan = $('#attachments_<%= j params[:attachment_id] %>');
<% if @attachment.new_record? %>
  fileSpan.hide();
  alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>");
<% else %>
$('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan);
fileSpan.find('a.remove-upload')
  .attr({
    "data-remote": true,
    "data-method": 'delete',
    href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
  })
  .off('click');
<% end %>