Commit 1d8d82b7 by Calen Pennington

Set id's on newly created components so that they are immediately editable

parent d3a734d2
...@@ -413,7 +413,7 @@ def clone_item(request): ...@@ -413,7 +413,7 @@ def clone_item(request):
modulestore().update_metadata(new_item.location.url(), new_item.own_metadata) modulestore().update_metadata(new_item.location.url(), new_item.own_metadata)
modulestore().update_children(parent_location, parent.definition.get('children', []) + [new_item.location.url()]) 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 cdodge: this method allows for POST uploading of files into the course asset library, which will
......
...@@ -32,14 +32,13 @@ class CMS.Views.ModuleEdit extends Backbone.View ...@@ -32,14 +32,13 @@ class CMS.Views.ModuleEdit extends Backbone.View
return _metadata return _metadata
cloneTemplate: (template, name) -> cloneTemplate: (template) ->
@$el.load("/clone_item", { $.post("/clone_item", {
parent_location: @$el.parent().data('id') parent_location: @$el.parent().data('id')
template: template template: template
name: name }, (data) =>
}, => @model.set(id: data.id)
@loadModules() @render()
@delegateEvents()
) )
render: -> render: ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment