diff -u b/formatters/accordion/accordion.js b/formatters/accordion/accordion.js --- b/formatters/accordion/accordion.js +++ b/formatters/accordion/accordion.js @@ -72,7 +72,7 @@ // Check if Accordion Items need to be hidden when the "state:visible" // event is fired. - $(document).once('fieldgroup_accordion_state_visible').bind('state:visible', function(e) { + $(once('fieldgroup_accordion_state_visible', 'body')).bind('state:visible', function(e) { if ($(e.target).hasClass('field-group-child-field')) { let $group = $(e.target).closest('.field-group-accordion-item'); if ($group.length !== 0) { @@ -87,4 +87,4 @@ } }; -})(jQuery); +})(Drupal, jQuery, once); diff -u b/formatters/details/details.js b/formatters/details/details.js --- b/formatters/details/details.js +++ b/formatters/details/details.js @@ -29,7 +29,7 @@ // Check if Details Field Groups need to be hidden when the // "state:visible" event is fired. - $(document).once('fieldgroup_details_state_visible').bind('state:visible', function(e) { + $(once('fieldgroup_details_state_visible', 'body')).bind('state:visible', function(e) { if ($(e.target).hasClass('field-group-child-field')) { let $group = $(e.target).closest('.field-group-details'); if ($group.length !== 0) { @@ -40,4 +40,4 @@ } }; -})(jQuery); +})(jQuery, once); diff -u b/formatters/fieldset/fieldset.js b/formatters/fieldset/fieldset.js --- b/formatters/fieldset/fieldset.js +++ b/formatters/fieldset/fieldset.js @@ -30,7 +30,7 @@ // Check if Fieldset Field Groups need to be hidden when the // "state:visible" event is fired. - $(document).once('fieldgroup_fieldset_state_visible').bind('state:visible', function(e) { + $(once('fieldgroup_fieldset_state_visible', 'body')).bind('state:visible', function(e) { if ($(e.target).hasClass('field-group-child-field')) { let $group = $(e.target).closest('.field-group-fieldset'); if ($group.length !== 0) { @@ -41,4 +41,4 @@ } }; -})(jQuery); +})(jQuery, once); diff -u b/formatters/html_element/html-element.js b/formatters/html_element/html-element.js --- b/formatters/html_element/html-element.js +++ b/formatters/html_element/html-element.js @@ -37,7 +37,7 @@ }); // Check if HTML element Field Groups need to be hidden when the // "state:visible" event is fired. - $(document).once('fieldgroup_html_element_state_visible').bind('state:visible', function(e) { + $(once('fieldgroup_html_element_state_visible', 'body')).bind('state:visible', function(e) { if ($(e.target).hasClass('field-group-child-field')) { let $group = $(e.target).closest('.field-group-details'); if ($group.length !== 0) { @@ -85,4 +85,4 @@ } }; -})(jQuery); +})(jQuery, once); diff -u b/formatters/tabs/tabs.js b/formatters/tabs/tabs.js --- b/formatters/tabs/tabs.js +++ b/formatters/tabs/tabs.js @@ -49,7 +49,7 @@ // Check if Tabs need to be hidden when the "state:visible" event is // fired. - $(document).once('fieldgroup_tabs_state_visible').bind('state:visible', function(e) { + $(once('fieldgroup_tabs_state_visible', 'body')).bind('state:visible', function(e) { if ($(e.target).hasClass('field-group-child-field')) { let $group = $(e.target).closest('.field-group-tab'); let $tab; @@ -69,4 +69,4 @@ } }; -})(jQuery, Modernizr); +})(jQuery, Modernizr, once); only in patch2: unchanged: --- a/field_group.libraries.yml +++ b/field_group.libraries.yml @@ -46,6 +46,7 @@ formatter.details: formatters/details/details.js: {} dependencies: - core/jquery + - core/once formatter.tabs: js: