ldc-ovoteam/public/modules/contrib/webform/js/webform.element.select.js
2024-02-06 10:27:42 +01:00

27 lines
736 B
JavaScript

/**
* @file
* JavaScript behaviors for select menu.
*/
(function ($, Drupal) {
'use strict';
/**
* Disable select menu options using JavaScript.
*
* @type {Drupal~behavior}
*/
Drupal.behaviors.webformSelectOptionsDisabled = {
attach: function (context) {
$('select[data-webform-select-options-disabled]', context).once('webform-select-options-disabled').each(function () {
var $select = $(this);
var disabled = $select.attr('data-webform-select-options-disabled').split(/\s*,\s*/);
$select.find('option').filter(function isDisabled() {
return ($.inArray(this.value, disabled) !== -1);
}).attr('disabled', 'disabled');
});
}
};
})(jQuery, Drupal);