Chris@1464: var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); Chris@1464: <% if @attachment.new_record? %> Chris@1464: fileSpan.hide(); Chris@1464: alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>"); Chris@1464: <% else %> Chris@1464: $('', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); Chris@1464: fileSpan.find('a.remove-upload') Chris@1464: .attr({ Chris@1464: "data-remote": true, Chris@1464: "data-method": 'delete', Chris@1464: href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' Chris@1464: }) Chris@1464: .off('click'); Chris@1464: <% end %>