(function() {
  var $el = $('#element_<%= @element.id %>');
  var $errors = $('#element_<%= @element.id %>_errors');
  $('> .element-content .content_editor, > .element-content .ingredient_editor', $el).removeClass('validation_failed');

<%- if @element_validated -%>

  $errors.hide();
  $el.trigger('SaveElement.Alchemy', {previewText: '<%= j sanitize(@element.preview_text) %>'});
  Alchemy.growl('<%= Alchemy.t(:element_saved) %>');
  Alchemy.PreviewWindow.refresh(function() {
    Alchemy.ElementEditors.focusElementPreview(<%= @element.id %>);
  });

<%- else -%>

  Alchemy.growl('<%= j @notice %>', 'warn');
  $errors.html('<%= j @error_message %><ul><li><%== j @error_messages.join("</li><li>") %></li></ul>');
  $errors.show();
  $('<%= @element.contents_with_errors.map { |content| "#" + content.dom_id }.join(", ") %>').addClass('validation_failed');
  $('<%== @element.ingredients_with_errors.map { |ingredient| "[data-ingredient-id=\"#{ingredient.id}\"]" }.join(", ") %>').addClass('validation_failed');
  Alchemy.Buttons.enable($el);

<%- end -%>
})();

(function() {
  var $el = $('#element_<%= @element.id %>');
  var $errors = $('#element_<%= @element.id %>_errors');
  $('> .element-content .content_editor, > .element-content .ingredient-editor', $el).removeClass('validation_failed');

<%- if @element_validated -%>

  $errors.hide();
  $el.trigger('SaveElement.Alchemy', {previewText: '<%= j sanitize(@element.preview_text) %>'});
  Alchemy.growl('<%= Alchemy.t(:element_saved) %>');
  Alchemy.PreviewWindow.refresh(function() {
    Alchemy.ElementEditors.focusElementPreview(<%= @element.id %>);
  });

<%- else -%>

  Alchemy.growl('<%= j @notice %>', 'warn');
  $errors.html('<%= j @error_message %><ul><li><%== j @error_messages.join("</li><li>") %></li></ul>');
  $errors.show();
  $('<%= @element.contents_with_errors.map { |content| "#" + content.dom_id }.join(", ") %>').addClass('validation_failed');
  $('<%== @element.ingredients_with_errors.map { |ingredient| "[data-ingredient-id=\"#{ingredient.id}\"]" }.join(", ") %>').addClass('validation_failed');
  Alchemy.Buttons.enable($el);

<%- end -%>
})();

Fix ingredient editor selector in element update callback
Fix ingredient editor selector in element update callback

The ingredient editor class name has a hyphen. Fixes a bug
where an element with failed ingredient validation did not
updated the UI accordingly after an element updated.
