Make onchange code simpler

This commit is contained in:
Luis Ramos
2020-09-01 14:52:18 +01:00
parent 46623242f7
commit 41d797489d

View File

@@ -35,7 +35,7 @@
%div{class: "field"}
= f.label :country_id, Spree.t(:country) + ':'
%span{id: "#{s_or_b}country"}
= f.collection_select :country_id, available_countries, :id, :name, {}, {class: 'select2 fullwidth'}
= f.collection_select :country_id, available_countries, :id, :name, {}, {class: 'select2 fullwidth', onchange: "update_state('#{s_or_b}')"}
%div{class: "field"}
= f.label :state_id, Spree.t(:state) + ':'
%span{id: "#{s_or_b}state"}
@@ -46,9 +46,3 @@
%div{class: "field"}
= f.label :phone, Spree.t(:phone) + ':'
= f.phone_field :phone, class: 'fullwidth'
- content_for :head do
= javascript_tag do
$(document).ready(function(){
$('span##{s_or_b}country .select2').on('change', function() { update_state('#{s_or_b}'); });
});