diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 9753f5bfd0..4a6cb4787b 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -413,7 +413,7 @@ def clone_item(request): modulestore().update_metadata(new_item.location.url(), new_item.own_metadata) modulestore().update_children(parent_location, parent.definition.get('children', []) + [new_item.location.url()]) - return preview_component(request, new_item.location) + return HttpResponse(json.dumps({'id': dest_location.url()})) ''' cdodge: this method allows for POST uploading of files into the course asset library, which will diff --git a/cms/static/coffee/src/views/module_edit.coffee b/cms/static/coffee/src/views/module_edit.coffee index 3116dfbb55..592c8a4640 100644 --- a/cms/static/coffee/src/views/module_edit.coffee +++ b/cms/static/coffee/src/views/module_edit.coffee @@ -32,14 +32,13 @@ class CMS.Views.ModuleEdit extends Backbone.View return _metadata - cloneTemplate: (template, name) -> - @$el.load("/clone_item", { + cloneTemplate: (template) -> + $.post("/clone_item", { parent_location: @$el.parent().data('id') template: template - name: name - }, => - @loadModules() - @delegateEvents() + }, (data) => + @model.set(id: data.id) + @render() ) render: -> diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 822628c9dd..b2a0f74f81 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -90,7 +90,7 @@ function saveNewComponent(e) { model: new CMS.Models.Module() }) - $('.components').append(editor.$el) + $newComponentItem.before(editor.$el) editor.cloneTemplate($(this).data('location'))