Skip to content

Commit

Permalink
Fix removing picture essences
Browse files Browse the repository at this point in the history
Prior to this commit, removing a picture would not
work because the click handler for the delete button
would delete the input field, removing Rails' ability
to actually update the content.
  • Loading branch information
mamhoff committed Aug 13, 2018
1 parent 58d8d40 commit 756e927
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions app/assets/javascripts/alchemy/alchemy.base.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ $.extend Alchemy,
$element = $form_field.closest(".element-editor")
if $form_field[0]
$form_field.val ""
$form_field.prev().remove()
$form_field.parent().html '<i class="icon far fa-image fa-fw"/>'
$element.find(".thumbnail_background").html('<i class="icon far fa-image fa-fw"/>')
Alchemy.setElementDirty $element
false

Expand Down
3 changes: 2 additions & 1 deletion app/views/alchemy/essences/_essence_picture_editor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<div class="thumbnail_background">
<%- if content.ingredient -%>
<%= essence_picture_thumbnail(content, options) %>
<%= hidden_field_tag content.form_field_name(:picture_id), content.ingredient.id %>
<% else %>
<%= render_icon(:image, style: 'regular') %>
<% end %>
Expand All @@ -43,6 +42,8 @@
} %>
</div>
</div>
<%= hidden_field_tag content.form_field_name(:picture_id),
content.ingredient.try!(:id) %>
<%= hidden_field_tag content.form_field_name(:link),
content.essence.link %>
<%= hidden_field_tag content.form_field_name(:link_title),
Expand Down

0 comments on commit 756e927

Please sign in to comment.