#link to open tabs

Hi,

What I would like to do is to open a tab with a #link. I tried all the threats I found related to this customization, but none of them works.

this is the code I placed in the ‘global js’ section

(function($){
          var tabnav = location.href.split("#tab-").slice(-1)[0];
         
          if ( tabnav || tabnav != '' ) {    
           
           $( document ).ready ( function() {
         
            console.log(tabnav);
         
            var navbar = $('.x-navbar').outerHeight();
         
            $('.x-nav-tabs .x-nav-tabs-item').removeClass('active');
            $('.x-nav-tabs .x-nav-tabs-item [data-cs-tab-toggle="' + tabnav + '"]').parent('.x-nav-tabs-item').addClass('active');
            $('.x-tab-content .x-tab-pane').removeClass('active');
            $('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').addClass('active');
         
            setTimeout ( function() { //Let's trigger the scroll animation just after the content is displayed.
           
            var yloc = $('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').offset().top;
            console.log($('.x-tab-content [data-cs-tab-index="' + tabnav + '"]').offset().top);
            console.log('tab: ' + tabnav + ', yloc: ' + yloc);
         
            $('html, body').animate({
                scrollTop: yloc
            }, 850, 'easeInOutExpo');
         
           }, 750 );
         
           } );
         
          }
         
        })(jQuery);

Can you place a working code to do so?

Thanks in advice

Hi Dario,

Thank you for writing in, no sorry we can not provide a custom code.

Please use the native Toggle Hash option of the Tabs element instead, please follow the following thread.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.