(function( $ ) {
|
|
'use strict';
|
|
|
|
$(function() {
|
|
|
|
$( '.wpcf7-state' ).change( function() {
|
|
|
|
var $city_select = $( '.wpcf7-city' );
|
|
|
|
$city_select.prop('disabled', true);
|
|
|
|
$.getJSON(
|
|
cf7_states_cities.rest_base + '/cities',
|
|
{ state: $(this).val() },
|
|
function ( response ) {
|
|
|
|
$city_select.find( 'option:not([value=""])' ).remove();
|
|
|
|
$.each( response, function( key, city ) {
|
|
$city_select.append('<option value=' + city + '>' + city + '</option>');
|
|
} );
|
|
|
|
$city_select.prop('disabled', false);
|
|
|
|
}
|
|
);
|
|
|
|
} );
|
|
|
|
});
|
|
|
|
})( jQuery );
|