From 1ef52c9c3d4ae1a5d07b5b83275e1d1962aec343 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 11 Jan 2016 12:02:51 +0100 Subject: [PATCH] [FIX] website_sale: state option in checkout page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit option.style.display = “none” not working in safari opw:665787 --- .../static/src/js/website_sale.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 0149232558d..a6c1ccc5c21 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -332,19 +332,23 @@ $('.oe_website_sale').each(function () { $('input.js_variant_change, select.js_variant_change', this).first().trigger('change'); }); + var state_options = $("select[name='state_id']:enabled option:not(:first)"); $(oe_website_sale).on('change', "select[name='country_id']", function () { - var $select = $("select[name='state_id']:enabled"); - $select.find("option:not(:first)").hide(); - var nb = $select.find("option[data-country_id="+($(this).val() || 0)+"]").show().size(); - $select.parent().toggle(nb>=1); + var select = $("select[name='state_id']"); + state_options.detach(); + var displayed_state = state_options.filter("[data-country_id="+($(this).val() || 0)+"]"); + var nb = displayed_state.appendTo(select).show().size(); + select.parent().toggle(nb>=1); }); $(oe_website_sale).find("select[name='country_id']").change(); + var shipping_state_options = $("select[name='shipping_state_id']:enabled option:not(:first)"); $(oe_website_sale).on('change', "select[name='shipping_country_id']", function () { - var $select = $("select[name='shipping_state_id']:enabled"); - $select.find("option:not(:first)").hide(); - var nb = $select.find("option[data-country_id="+($(this).val() || 0)+"]").show().size(); - $select.parent().toggle(nb>=1); + var select = $("select[name='shipping_state_id']"); + shipping_state_options.detach(); + var displayed_state = shipping_state_options.filter("[data-country_id="+($(this).val() || 0)+"]"); + var nb = displayed_state.appendTo(select).show().size(); + select.parent().toggle(nb>=1); }); $(oe_website_sale).find("select[name='shipping_country_id']").change(); });