(function() { var $el = $('#element_<%= @element.id %>'); $('.content_editor', $el).removeClass('validation_failed'); <%- if @element_validated -%> $('.element_head', $el).replaceWith('<%= j render("element_head", element: @element) %>'); Alchemy.ElementEditors.reinit($el); $("#element_<%= @element.id %>_errors").hide(); Alchemy.setElementSaved($el); Alchemy.growl('<%= _t(:element_saved) %>'); Alchemy.PreviewWindow.refresh(function() { Alchemy.ElementEditors.selectElementInPreview(<%= @element.id %>); }); <%= update_essence_select_elements(@page, @element) -%> <%- else -%> Alchemy.growl('<%= j @notice %>', 'warn'); $('#element_<%= @element.id %>_errors').html('<%= j @error_message %>'); $("#element_<%= @element.id %>_errors").show(); $('<%= @element.contents_with_errors.map { |content| "#" + content.dom_id }.join(", ") %>').addClass('validation_failed'); Alchemy.ElementEditors.scrollToElement('#element_<%= @element.id %>'); Alchemy.Buttons.enable($el); <%- end -%> })();