engine/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee

30 lines
665 B
CoffeeScript

Locomotive.Views.Pages ||= {}
class Locomotive.Views.Pages.EditView extends Locomotive.Views.Pages.FormView
save: (event) ->
event.stopPropagation() & event.preventDefault()
@clear_errors()
@model.save {},
success: (model, response, xhr) =>
model._normalize()
$.growl('success', xhr.getResponseHeader('X-Message'))
if model.get('template_changed') == true
@reset_editable_elements()
else
@refresh_editable_elements()
error: (model, xhr) =>
errors = JSON.parse(xhr.responseText)
@show_errors errors
$.growl('error', xhr.getResponseHeader('X-Message'))