wiki-grav/plugins/admin/themes/grav/app/forms/fields/elements.js
2022-05-18 09:46:26 +02:00

13 lines
400 B
JavaScript

import $ from 'jquery';
$(document).on('change', '[data-grav-elements] select', (event) => {
const target = $(event.currentTarget);
const value = target.val();
const id = target.closest('[data-grav-elements]').data('gravElements');
$(`[id^="${id}_"]`).css('display', 'none');
$(`[id="${id}__${value}"]`).css('display', 'inherit');
});
$('[data-grav-elements] select').trigger('change');