Fix removal of producer properties - remove href attr so Spree doesn't attempt an XHR

This commit is contained in:
Rohan Mitchell
2016-12-23 15:10:36 +11:00
committed by Rob Harrington
parent bfaaf16030
commit ac8cfe24e6
2 changed files with 12 additions and 1 deletions

View File

@@ -23,6 +23,17 @@ module Spree
link_to_with_icon('icon-trash', name, '#', html_options) + f.hidden_field(:_destroy)
end
def link_to_remove_fields_without_url(name, f, options = {})
name = '' if options[:no_text]
options[:class] = '' unless options[:class]
options[:class] += 'no-text with-tip' if options[:no_text]
html_options = {class: "remove_fields #{options[:class]}", data: {action: 'remove'}, title: t(:remove)}
html_options.merge!(options[:html]) if options.key? :html
link_to_with_icon('icon-trash', name, '#', html_options).gsub('href="#" ', '').html_safe +
f.hidden_field(:_destroy)
end
end
end
end

View File

@@ -12,4 +12,4 @@
= f.text_field :value, :class => 'autocomplete'
%td.actions
- unless @enterprise.producer_properties.empty?
= link_to_remove_fields t(:remove), f, no_text: true, url: (f.object.persisted? && main_app.admin_enterprise_producer_property_path(@enterprise, f.object)), html: {"onclick" => "if(typeof(enterprise_form) != 'undefined') { angular.element(enterprise_form).scope().setFormDirty() }".html_safe}
= link_to_remove_fields_without_url t(:remove), f, no_text: true, html: {"onclick" => "if(typeof(enterprise_form) != 'undefined') { angular.element(enterprise_form).scope().setFormDirty() }".html_safe}