(function ($, Drupal, once) {
  Drupal.behaviors.castorcitoFieldListText = {
    attach: function (context, settings) {
      $(once('ccavm', '#cc-allowed-values-modal', context)).on('click', function (e) {
        e.preventDefault();

        Drupal.ajax({
          url: e.currentTarget.href,
          dialogType: 'modal',
          dialog: {width: 1000},
          submit: {
            allowed_values_data: $('#cc-allowed-values-data-hidden').val() || '',
          }
        }).execute();
      });
    },
  };
})(jQuery, Drupal, once);