@@ -1,4 +1,8 | |||||
1 | var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); |
|
1 | var fileSpan = $('#attachments_<%= j params[:attachment_id] %>'); | |
|
2 | <% if @attachment.new_record? %> | |||
|
3 | fileSpan.hide(); | |||
|
4 | alert("<%= escape_javascript @attachment.errors.full_messages.join(', ') %>"); | |||
|
5 | <% else %> | |||
2 | $('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); |
|
6 | $('<input>', { type: 'hidden', name: 'attachments[<%= j params[:attachment_id] %>][token]' } ).val('<%= j @attachment.token %>').appendTo(fileSpan); | |
3 | fileSpan.find('a.remove-upload') |
|
7 | fileSpan.find('a.remove-upload') | |
4 | .attr({ |
|
8 | .attr({ | |
@@ -7,3 +11,4 fileSpan.find('a.remove-upload') | |||||
7 | href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' |
|
11 | href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' | |
8 | }) |
|
12 | }) | |
9 | .off('click'); |
|
13 | .off('click'); | |
|
14 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now