2011-11-16 00:39:16 +00:00
|
|
|
Locomotive.Views.Pages ||= {}
|
|
|
|
|
|
|
|
class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
|
|
|
|
|
|
|
|
save: (event) ->
|
2011-11-25 01:04:42 +00:00
|
|
|
event.stopPropagation() & event.preventDefault()
|
|
|
|
|
2012-04-16 09:38:32 +00:00
|
|
|
form = $(event.target).trigger('ajax:beforeSend')
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
@clear_errors()
|
|
|
|
|
|
|
|
@model.save {},
|
|
|
|
success: (model, response, xhr) =>
|
2012-04-16 09:38:32 +00:00
|
|
|
form.trigger('ajax:complete')
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
model._normalize()
|
|
|
|
|
|
|
|
if model.get('template_changed') == true
|
|
|
|
@reset_editable_elements()
|
|
|
|
else
|
|
|
|
@refresh_editable_elements()
|
|
|
|
|
|
|
|
error: (model, xhr) =>
|
2012-04-16 09:38:32 +00:00
|
|
|
form.trigger('ajax:complete')
|
|
|
|
|
2011-11-25 01:04:42 +00:00
|
|
|
errors = JSON.parse(xhr.responseText)
|
|
|
|
|
|
|
|
@show_errors errors
|