diff --git a/cms/static/js/views/assets.js b/cms/static/js/views/assets.js index 9eb521dcb6..18ef131f52 100644 --- a/cms/static/js/views/assets.js +++ b/cms/static/js/views/assets.js @@ -9,7 +9,7 @@ function removeAsset(e){ e.preventDefault(); var that = this; - var msg = new CMS.Models.ConfirmAssetDeleteMessage({ + var msg = new CMS.Views.Prompt.Confirmation({ title: gettext("Delete File Confirmation"), message: gettext("Are you sure you wish to delete this item. It cannot be reversed!\n\nAlso any content that links/refers to this item will no longer work (e.g. broken images and/or links)"), actions: { @@ -17,15 +17,17 @@ function removeAsset(e){ text: gettext("OK"), click: function(view) { // call the back-end to actually remove the asset - $.post(view.model.get('remove_asset_url'), - { 'location': view.model.get('asset_location') }, + var url = $('.asset-library').data('remove-asset-callback-url'); + var row = $(that).closest('tr'); + $.post(url, + { 'location': row.data('id') }, function() { // show the post-commit confirmation $(".wrapper-alert-confirmation").addClass("is-shown").attr('aria-hidden','false'); - view.model.get('row_to_remove').remove(); + row.remove(); analytics.track('Deleted Asset', { 'course': course_location_analytics, - 'id': view.model.get('asset_location') + 'id': row.data('id') }); } ); @@ -38,24 +40,9 @@ function removeAsset(e){ view.hide(); } }] - }, - remove_asset_url: $('.asset-library').data('remove-asset-callback-url'), - asset_location: $(this).closest('tr').data('id'), - row_to_remove: $(this).closest('tr') + } }); - - // workaround for now. We can't spawn multiple instances of the Prompt View - // so for now, a bit of hackery to just make sure we have a single instance - // note: confirm_delete_prompt is in asset_index.html - if (confirm_delete_prompt === null) - confirm_delete_prompt = new CMS.Views.Prompt({model: msg}); - else - { - confirm_delete_prompt.model = msg; - confirm_delete_prompt.show(); - } - - return; + return msg.show(); } function showUploadModal(e) { @@ -125,4 +112,4 @@ function displayFinishedUpload(xhr) { 'course': course_location_analytics, 'asset_url': resp.url }); -} \ No newline at end of file +} diff --git a/cms/static/js/views/feedback.js b/cms/static/js/views/feedback.js index b04fb6e3d1..0cfd6fa4ef 100644 --- a/cms/static/js/views/feedback.js +++ b/cms/static/js/views/feedback.js @@ -90,6 +90,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({ var parent = CMS.Views[_.str.capitalize(this.options.type)]; if(parent && parent.active && parent.active !== this) { parent.active.stopListening(); + parent.active.undelegateEvents(); } this.$el.html(this.template(this.options)); parent.active = this; diff --git a/cms/templates/asset_index.html b/cms/templates/asset_index.html index 0006d29d38..abbc5bb1b4 100644 --- a/cms/templates/asset_index.html +++ b/cms/templates/asset_index.html @@ -8,11 +8,6 @@ <%block name="jsextra"> - - <%block name="content"> @@ -98,7 +93,7 @@ - + % endfor