Merge pull request #21733 from woocommerce/fix/21642

Trigger a country select change on initial load
This commit is contained in:
Claudiu Lodromanean 2018-10-30 09:53:16 -07:00 committed by GitHub
commit 7d7e49bd8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 109 additions and 110 deletions

View File

@ -6,8 +6,7 @@ jQuery( function( $ ) {
return false;
}
var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ),
locale = $.parseJSON( locale_json );
var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), locale = $.parseJSON( locale_json );
function field_is_required( field, is_required ) {
if ( is_required ) {
@ -27,11 +26,8 @@ jQuery( function( $ ) {
}
}
$( document.body )
// Handle locale
.bind( 'country_to_state_changing', function( event, country, wrapper ) {
$( document.body ).bind( 'country_to_state_changing', function( event, country, wrapper ) {
var thisform = wrapper, thislocale;
if ( typeof locale[ country ] !== 'undefined' ) {
@ -129,4 +125,7 @@ jQuery( function( $ ) {
rows.detach().appendTo( wrapper );
} );
});
// Make sure the locales are loaded on first page load.
$( '#billing_country' ).trigger( 'change' );
});