Change delete_item to RESTful URL.

Part of STUD-847.
This commit is contained in:
cahrens
2013-11-01 14:39:23 -04:00
parent b489514096
commit 16766a5ee9
21 changed files with 172 additions and 106 deletions

View File

@@ -70,6 +70,7 @@ define ["backbone", "jquery", "underscore", "gettext", "xblock/runtime.v1",
(data) =>
@model.set(id: data.id)
@$el.data('id', data.id)
@$el.data('update_url', data.update_url)
@render()
)

View File

@@ -82,9 +82,10 @@ define ["jquery", "jquery.ui", "backbone", "js/views/feedback_prompt", "js/views
deleting = new NotificationView.Mini
title: gettext('Deleting…')
deleting.show()
$.postJSON('/delete_item', {
id: $component.data('id')
}, =>
$.ajax({
type: 'DELETE',
url: $component.data('update_url')
}).success(=>
$component.remove()
deleting.hide()
)

View File

@@ -134,9 +134,10 @@ define ["jquery", "jquery.ui", "gettext", "backbone",
title: gettext('Deleting…'),
deleting.show()
$component = $(event.currentTarget).parents('.component')
$.postJSON('/delete_item', {
id: $component.data('id')
}, =>
$.ajax({
type: 'DELETE',
url: $component.data('update_url')
}).success(=>
deleting.hide()
analytics.track "Deleted a Component",
course: course_location_analytics
@@ -162,16 +163,16 @@ define ["jquery", "jquery.ui", "gettext", "backbone",
deleteDraft: (event) ->
@wait(true)
$.ajax({
type: 'DELETE',
url: @$el.data('update_url') + "?" + $.param({recurse: true})
}).success(=>
$.postJSON('/delete_item', {
id: @$el.data('id')
delete_children: true
}, =>
analytics.track "Deleted Draft",
course: course_location_analytics
unit_id: unit_location_analytics
analytics.track "Deleted Draft",
course: course_location_analytics
unit_id: unit_location_analytics
window.location.reload()
window.location.reload()
)
createDraft: (event) ->