Home Forums Space themes support forum Single product accordeon tabs

Single product accordeon tabs

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #632361

    John
    Participant

    Hello guys,
    I m trying with this js to close the first tab of accordeon. After i open the first tab from accordeon and i want to click on the second tab of the accordeon to open it i want to automaticaly close the first tab.
    Attached in privet the code and the website link. We are using vega theme.
    Can you guys help me?
    Thank you!

    #632410

    Luke Nielsen
    Keymaster

    Hello,

    Try to create a preset for the Product page and in Performance -> Script never load -> disable the Accordion element init: https://monosnap.com/file/s3cA0cetM3Sewscyxuv8nYYgwKugBe

    https://monosnap.com/file/XMnbwz3mBOBjLiWFtCWjUW4cTOfzf2

    Kind Regards

    #632482

    John
    Participant

    Hey Luke, many thanks for fast answer.
    Actually doing what you said blocks the javascript to load on the page, corect?
    I would like if possible to have the first tab closed by default and if other tabs are opened to closed previous one.
    Thank you again for your support.

    #632566

    Luke Nielsen
    Keymaster

    Hello,

    In this case, remove the previously created preset and put the below custom to Theme settings -> Custom js -> Global js.

    jQuery(document).ready(function ($) {
       setTimeout(function () {
          var $firstAccordionItem = $('.xts-accordion-item').first();
          
          if ($firstAccordionItem.length) {
              var $content = $firstAccordionItem.find('.xts-accordion-content');
              var $title = $firstAccordionItem.find('.xts-accordion-title');
      
              if ($content.length) {
                  $content.css('display', 'none');
              }
      
              if ($title.length) {
                  $title.removeClass('xts-active');
              }
      
              $firstAccordionItem.removeClass('xts-active');
          }
      }, 10);
    
       $('.wc-tabs-wrapper').each(function () {
          var $wrapper = $(this);
          var $tabTitles = $wrapper.find('.xts-accordion-title');
          var $tabContents = $wrapper.find('.xts-accordion-content');
          var activeClass = 'xts-active';
          var time = 300;
    
          $tabTitles.on('click', function () {
             $clickedTitle   = $(this);
             $clickedContent = $(this).parent().find('.xts-accordion-content');
              
             $tabTitles.not($clickedTitle).removeClass(activeClass);
             $tabContents.not($clickedContent).stop().slideUp(time).removeClass(activeClass);
          });
       });
    });

    Clear the cache and check how it works.

    Kind Regards

    #632567

    John
    Participant

    Lukas, you are the man. Many thanks and much appreciation. Works flawless. Please consider add this feature in the future :D. Thanks again and have a wonderful weekend.
    Again much pleased with xtemos support. Top notch.

Viewing 5 posts - 1 through 5 (of 5 total)