Commit 83b3d51f by Calen Pennington

Wire up the cancel button in the unit editor

parent 72eef72d
bind_edit_links = -> class @CMS
$('a.module-edit').click -> @bind = =>
edit_item($(this).attr('id')) $('a.module-edit').click ->
return false CMS.edit_item($(this).attr('id'))
return false
edit_item = (id) => @edit_item = (id) =>
$.get('/edit_item', {id: id}, (data) => $.get('/edit_item', {id: id}, (data) =>
$('#module-html').empty().append(data) $('#module-html').empty().append(data)
bind_edit_links() CMS.bind()
$('section.edit-pane').show() $('section.edit-pane').show()
$('body').addClass('content') $('body').addClass('content')
new @Unit('unit-wrapper', id) new Unit('unit-wrapper', id)
) )
$ -> $ ->
$.ajaxSetup $.ajaxSetup
...@@ -73,5 +74,5 @@ $ -> ...@@ -73,5 +74,5 @@ $ ->
$('section.edit-pane').show() $('section.edit-pane').show()
return false return false
bind_edit_links() CMS.bind()
...@@ -2,12 +2,14 @@ class @Unit ...@@ -2,12 +2,14 @@ class @Unit
constructor: (@element_id, @module_id) -> constructor: (@element_id, @module_id) ->
@module = new window[$("##{@element_id}").attr('class')] 'module-html' @module = new window[$("##{@element_id}").attr('class')] 'module-html'
$("##{@element_id} .save-update").click( (event) => $("##{@element_id} .save-update").click (event) =>
event.preventDefault() event.preventDefault()
$.post("save_item", { $.post("save_item", {
id: @module_id id: @module_id
data: JSON.stringify(@module.save()) data: JSON.stringify(@module.save())
}) })
) $("##{@element_id} .cancel").click (event) =>
event.preventDefault()
CMS.edit_item(@module_id)
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