From 94a9b5e004db7b5f6ec6cdffccf4287b9e47c50a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 7 Oct 2014 20:05:50 +0200 Subject: [PATCH] empty() .attachment (remove spaces) to keep css working, thanks @mrflix :-o --- .../controllers/_application_controller_form.js.coffee | 10 +++++++++- .../javascripts/app/controllers/ticket_zoom.js.coffee | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index b679e9ff1..7ece127f7 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -730,6 +730,8 @@ class App.ControllerForm extends App.Controller item ) store_id = $(e.currentTarget).data('id') + + # delete attachment from storage App.Ajax.request( type: 'DELETE' url: App.Config.get('api_path') + '/ticket_attachment_upload' @@ -737,7 +739,13 @@ class App.ControllerForm extends App.Controller processData: false success: (data, status, xhr) => ) - $(e.currentTarget).closest('.attachment').empty() + + # remove attachment from dom + element = $(e.currentTarget).closest('.attachments') + $(e.currentTarget).closest('.attachment').remove() + # empty .attachment (remove spaces) to keep css working, thanks @mrflix :-o + if element.find('.attachment').length == 0 + element.empty() ) @attachments = [] diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 54a93c4bb..0f33d74b1 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -1089,6 +1089,8 @@ class Edit extends App.Controller item ) store_id = $(e.currentTarget).data('id') + + # delete attachment from storage App.Ajax.request( type: 'DELETE' url: App.Config.get('api_path') + '/ticket_attachment_upload' @@ -1096,7 +1098,13 @@ class Edit extends App.Controller processData: false success: (data, status, xhr) => ) - $(e.currentTarget).closest('.attachment').empty() + + # remove attachment from dom + element = $(e.currentTarget).closest('.attachments') + $(e.currentTarget).closest('.attachment').remove() + # empty .attachment (remove spaces) to keep css working, thanks @mrflix :-o + if element.find('.attachment').length == 0 + element.empty() ) reset: (e) =>