Viewing 23 posts - 1 through 23 (of 23 total)
  • Author
    Posts
  • #1090740

    Dear enfold Support Team,

    it seems, that I have a similar problem as decribed (and solved) in this thread:
    https://kriesi.at/support/topic/anchor-links-not-scrolling-to-tab-section-tabs/#post-874435

    My setting:

    I have a Tab-Section containing two Tabs: “Features” and “Technische Daten”.

    On the same page there are two buttons which should jump to two Tabs in the Tab-Section. The URL in den Button-Defintion contains https://domain.de/page/#features (and https://domain.de/page/#technische-daten for the second button).

    I included the script of the thread mentioned above in the functions.php in my enfold-child-theme.

    But nothing happens when I click the buttons.

    Is there anything more that I must consider?

    Thanks and beste regards
    Jan

    #1091274

    Any Ideas?

    #1091374

    Hi,

    Thank you for using Enfold.

    Where did you add the buttons? You may need to change the selectors in the “scrollToTab” function to that of the button’s class attribute.

    scrollToTab( '.menu-item a', 'click' );
    scrollToTab( window, 'load' );
    

    Best regards,
    Ismael

    #1091507
    This reply has been marked as private.
    #1091555
    This reply has been marked as private.
    #1092519

    Hi,

    Thanks for the update.

    Try to adjust the selector used in this function:

    scrollToTab( '.menu-item a', 'click' );
    

    .. with the button’s class attribute.

    scrollToTab( '.avia-buttonrow-wrap a', 'click' );
    

    You can also turn on the custom css class field if you want to manually specify the selector.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#turn-on-custom-css-class-field-for-all-alb-elements

    Best regards,
    Ismael

    #1092959

    Hi Ismael,

    Thank you very much for yout hint!

    I changed the one line you mentioned in the code which I pasted into the functions.php in my child-Theme and put only the Anchor in the URL-Field of the Buttons, but nothing happens. The Anchor seems to be correct, when I directly click on the Tab, the URL des not change.

    Do you habe any additional hind where to look?

    Thanks and best regards
    Jan

    #1092962
    This reply has been marked as private.
    #1093195

    Hi,

    Thanks for the update.

    The selector in the function is still the same.

    scrollToTab( '.menu-item a', 'click' );
    

    Try to replace it with:

    scrollToTab( '.avia-buttonrow-wrap a', 'click' );
    

    Best regards,
    Ismael

    #1093313
    This reply has been marked as private.
    #1093470

    Hey!

    Thanks for the update.

    We modified this line a bit.

    tab = $('.av-section-tab-title[href="'+ hash +'"]');
    

    It should work now. Please don’t forget to purge the cache prior to checking the page.

    Cheers!
    Ismael

    #1093576

    Ismael,

    thank you very much for your patience!
    It works perfectly now.

    Thanks and best regards
    Jan

    #1093586

    I’d like to summarize the results, maybe that’ll help someone later.

    The Goal was to scroll to a Tab-Section and switch to a specific tab (using an Anchor in the URL doesnt work in this setting).

    This code must be added to the functions.php:

    // custom script
    add_action( 'wp_footer', 'ava_custom_script_tab_section' );
    function ava_custom_script_tab_section() {
    ?>
    <script type="text/javascript">
    (function($) {
    	function scrollToTab(s, e,) {
    		$(s).on(e, function(event) {
    			var anchor, loc, cur, hash, tab, parent, pos;
    
    			if( e == 'load' ) {
    				loc  = window.location.hash;
    				hash = loc;
    			} else {
    				loc = $(this).attr('href');
    				hash = loc.substring(loc.indexOf('#'));
    			}
    	
    			tab = $('.av-section-tab-title[href="'+ hash +'"]');
    			parent = tab.parents('.av-tab-section-outer-container');
    			pos = parent.offset();
    
    			tab.trigger('click');
    			
    			if(hash) {
    				setTimeout( function() {
    					$(window).scrollTop( pos.top - 100 )
    				}, 100 );
    			}
    		});
    	}
    
    	scrollToTab( '.avia-buttonrow-wrap a', 'click' );
    	scrollToTab( window, 'load' );
    })(jQuery);
    </script>
    <?php
    }

    The code above works, if the scrolling is triggered by a click on a button in a “Button Row” element.

    The line

    scrollToTab( '.avia-buttonrow-wrap a', 'click' );

    must be cahnged if a click in a menu or another element should trigger the action.

    #1093952

    Hi,

    Glad it worked. And thank you for the follow up. Please don’t hesitate to open a new thread if you need anything else.

    Have a nice day.

    Best regards,
    Ismael

    #1116133

    Thanks for including the solution! I’m trying to route links in my footer to open a corresponding tab. As jan_behr kindly pointed out,

    The line
    scrollToTab( ‘.avia-buttonrow-wrap a’, ‘click’ );
    must be changed if a click in a menu or another element should trigger the action.

    What would the code be to open a tab from a link in the footer?

    For example, I have a page with 7 tabs on it. I’ve also placed the corresponding 7 in the footer. My desire is to have the footer links jump/scroll to the exact tab.

    Tks for the help in advance.

    • This reply was modified 5 years, 5 months ago by Jen.
    #1116557

    Hi,

    You need to change the selector used in this function or line.

    scrollToTab( '.avia-buttonrow-wrap a', 'click' );
    

    Replace “.avia-buttonrow-wrap a” with the footer links selector.

    Best regards,
    Ismael

    #1116777

    Yes, the code scrollToTab( ‘.avia-buttonrow-wrap a’, ‘click’ ); must to be replaced, but with what please? That was the question. Determining the correct selector hasn’t worked out in the past on this child theme. Broke my site following the last one. Trying to make sure I have it right before plugging in things.

    Tks

    #1116781

    Again, the source is a manual link placed inside a Text widget.

    #1116998

    Hi,

    If the link is on a widget inside the footer container, then this should work.

    scrollToTab( '#footer .widget a', 'click' );
    

    Best regards,
    Ismael

    #1117219

    Worked like a charm, Ismael.

    Enfold is easily the #1 WordPress theme out there because of this support. I’d buy it ten times over.

    Thank you.

    #1117453

    Hey Nicole,

    I’m glad this was resolved for you! If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

    #1317127

    @admin
    pls delete, it was posted by mistake
    thanks
    Jan

    #1317240

    Hi Jan,

    Thanks for letting us know. Would it be ok to close this thread for now?

    Best regards,
    Rikard

Viewing 23 posts - 1 through 23 (of 23 total)
  • You must be logged in to reply to this topic.