diff --git a/page_manager_ui/js/page-manager-ui-page-variants.js b/page_manager_ui/js/page-manager-ui-page-variants.js index 32f733b..3d579fb 100644 --- a/page_manager_ui/js/page-manager-ui-page-variants.js +++ b/page_manager_ui/js/page-manager-ui-page-variants.js @@ -6,11 +6,13 @@ Drupal.behaviors.pageManagerVariantsAdmin = { attach: function (context, settings) { // When the page loads find the Current Variant and activate its label and content. - $('.current_variant').parents('.page__section__2').addClass('active'); - $('.current_variant').parents('.page__section__2').siblings('.page__section__label').addClass('active current_variant'); + $('.current_variant', context).once('page-manager-current-variant').each(function() { + $(this).parents('.page__section__2').addClass('active'); + $(this).parents('.page__section__2').siblings('.page__section__label').addClass('active current_variant'); + }); // When the label is clicked show the variant settings. - $('.page__section_item__1 > .page__section__label').click(function() { + $('.page__section_item__1 > .page__section__label', context).once('page-manager-settings').click(function() { if ($(this).hasClass('active')) { $(this).removeClass('active'); $(this).siblings('.page__section__2').removeClass('active'); diff --git a/page_manager_ui/page_manager_ui.libraries.yml b/page_manager_ui/page_manager_ui.libraries.yml index 96130ef..e717845 100644 --- a/page_manager_ui/page_manager_ui.libraries.yml +++ b/page_manager_ui/page_manager_ui.libraries.yml @@ -12,3 +12,4 @@ page_variants: js/page-manager-ui-page-variants.js: {} dependencies: - core/jquery + - core/jquery.once