-
AuthorPosts
-
April 14, 2019 at 9:27 pm #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-874435My 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
JanApril 16, 2019 at 8:02 am #1091274Any Ideas?
April 16, 2019 at 11:00 am #1091374Hi,
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,
IsmaelApril 16, 2019 at 4:23 pm #1091507This reply has been marked as private.April 16, 2019 at 4:40 pm #1091555This reply has been marked as private.April 19, 2019 at 1:46 am #1092519Hi,
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.
Best regards,
IsmaelApril 20, 2019 at 8:09 pm #1092959Hi 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
JanApril 20, 2019 at 8:25 pm #1092962This reply has been marked as private.April 22, 2019 at 2:16 am #1093195Hi,
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,
IsmaelApril 22, 2019 at 12:15 pm #1093313This reply has been marked as private.April 23, 2019 at 2:35 am #1093470Hey!
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!
IsmaelApril 23, 2019 at 9:07 am #1093576Ismael,
thank you very much for your patience!
It works perfectly now.Thanks and best regards
JanApril 23, 2019 at 9:24 am #1093586I’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.
April 24, 2019 at 1:17 pm #1093952Hi,
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,
IsmaelJuly 6, 2019 at 3:19 am #1116133Thanks 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, 4 months ago by Jen.
July 8, 2019 at 5:38 am #1116557Hi,
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,
IsmaelJuly 8, 2019 at 10:32 pm #1116777Yes, 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
July 8, 2019 at 10:41 pm #1116781Again, the source is a manual link placed inside a Text widget.
July 9, 2019 at 10:34 am #1116998Hi,
If the link is on a widget inside the footer container, then this should work.
scrollToTab( '#footer .widget a', 'click' );
Best regards,
IsmaelJuly 9, 2019 at 10:09 pm #1117219Worked 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.
July 10, 2019 at 1:15 pm #1117453Hey 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 ShannonAugust 17, 2021 at 10:13 am #1317127@admin
pls delete, it was posted by mistake
thanks
JanAugust 18, 2021 at 4:25 am #1317240 -
AuthorPosts
- You must be logged in to reply to this topic.