/** * @file * Remove button for the Address field. */ (function ($, Drupal) { 'use strict'; Drupal.behaviors.addressFilterBehaviour = { attach: function (context) { $('.address-filer-country').once('address-filter-behaviour').on('change', function () { let countryElement = $(this); $.get('/pos_field_address/country-schema?country=' + $(this).val(), function (data) { let element = $(countryElement.data('schema-selector')); element.empty(); $.each(data, function (key,value) { element.append($('<option></option>') .attr('value', key).text(value)); }); element.trigger('change'); }, 'json'); $.get('/pos_field_address/schema-options?country=' + $(this).val() + '&schema=' + 'settlement', function (data) { let newElement = $(countryElement.data('value-selector')); newElement.empty(); $.each(data, function (key, value) { newElement.append($('<option></option>') .attr('value', key).text(value)); }); newElement.trigger('change'); }) }); $('.address-filter-schema').once('address-filter-behaviour').on('change', function () { let schemaElement = $(this); let countryCode = $(schemaElement.data('country-selector')).val(); $.get('/pos_field_address/schema-options?country=' + countryCode + '&schema=' + schemaElement.val(), function (data) { let element = $(schemaElement.data('value-selector')); element.empty(); $.each(data, function (key,value) { element.append($('<option></option>') .attr('value', key).text(value)); }); }, 'json'); }); } }; })(jQuery, Drupal);