Tagged: x
-
AuthorPosts
-
July 14, 2016 at 1:07 pm #1087221
Hello,
Is there any new code for having a link at the bottom of the content on one tab to open the next tab?
I have gone through all the different threads and they do not seem to work.
Or is there shortcode for the tabs that they can be listed at the bottom as well? On mobile the tab content is long so it is not as usable.
Thanks!
July 14, 2016 at 5:40 pm #1087541Hi there,
Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
July 15, 2016 at 1:01 pm #1088855Here is the URL:
http://www.restorevisioncenters.com/lasik/procedure-to-recoveryThanks!
July 15, 2016 at 11:35 pm #1089527Hello There,
Thanks for providing the url of your site. To open the next tab with a link, please add the following JS code in the customizer, Appearance > Customize > Custom > Javascript
(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 [data-cs-tab-toggle="' + tabnav + '"]').trigger('click'); 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);
And then at the bottom of your tab content, you add a custom html code:
<a href="#tab-1">Open the next Tab</a>
Please make sure that the tab number corresponds to the number of the next tab. Hope this make sense.
July 18, 2016 at 9:38 am #1091912Thanks for getting back to me. I added the javascript and the link at the bottom … it did not do anything.
July 18, 2016 at 10:48 am #1092027Hi again,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / passwordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
July 18, 2016 at 11:59 am #1092121This reply has been marked as private.July 18, 2016 at 9:29 pm #1092836Hi There,
Thank you for the credentials.
Please try to update the code to this:
(function($){ $('.open-next-tab').click(function(e){ e.preventDefault(); tabnav = $(this).attr('href').split("#tab-").slice(-1)[0];; var navbar = $('.x-navbar').outerHeight(); $('.x-nav-tabs .x-nav-tabs-item [data-cs-tab-toggle="' + tabnav + '"]').trigger('click'); setTimeout ( function() { //Let's trigger the scroll animation just after the content is displayed. var yloc = $('.x-tab-content').offset().top-100; console.log($('.x-tab-content [data-cs-tab-index="' + tabnav + '"]')); console.log('tab: ' + tabnav + ', yloc: ' + yloc); $('html, body').animate({ scrollTop: yloc }, 850, 'easeInOutExpo'); }, 750 ); }); })(jQuery);
Then the link should have class. If you add the following link at the end of your first content tab it will open the next tab.
<a href="#tab-2" class="open-next-tab">Open the next Tab</a>
Hope this helps.
July 19, 2016 at 9:43 am #1093607It worked!! Thank you so much for your help!
July 19, 2016 at 10:24 am #1093668Glad to hear.
Let us know if you need further help.
Joao
September 5, 2016 at 7:52 am #1161598Hello,
I kind of want to reach a similar goal and tried the code mentioned above on my site too. I certainly manage to scroll down to the relevant tab but still it doesn’t open. I tried numerous other javascript codes from other threads, none of them worked (guess most of them are outdated due to the change from id to index?!).
Is it even possible to have a link (on the same page) that allows scrolling down and open the relevant tab? (I used the “Accordion” element in Cornerstone)
Thanks a lot for your help!
Best,
JuliaSeptember 5, 2016 at 8:00 am #1161612This reply has been marked as private.September 5, 2016 at 8:11 pm #1162373Hi,
Thanks for providing your login credentials.
Please note that the code above is for tabs and yours is accordion.
I went ahead and change your js code to this.
(function($){ $('.open-accordion').click(function(e){ e.preventDefault(); myid = $(this).attr('href'); var navbar = $('.x-navbar').outerHeight(); var adminbar = $('#wpadminbar').outerHeight(); $('.x-accordion .x-accordion-body').removeClass('in'); $('.x-accordion>'+myid+ ' .x-accordion-toggle').trigger('click'); setTimeout ( function() { //Let's trigger the scroll animation just after the content is displayed. var yloc = $(myid).offset().top-navbar-adminbar; $('html, body').animate({ scrollTop: yloc }, 850, 'easeInOutExpo'); }, 750 ); }); })(jQuery);
I created links for the first three, kindly add an id to each accordion item ie. accordion1, accordion2, accordion3….
Then create links targeting those ids
eg.
<a href="#accordion1" class="open-accordion">Accordion 1</a> <a href="#accordion2" class="open-accordion">Accordion 2</a> <a href="#accordion3" class="open-accordion">Accordion 3</a>
Hope that helps
September 6, 2016 at 2:07 am #1162621Wow, that’s amazing! Works perfectly.
Thanks a lot for your effort.
Best,
JuliaSeptember 6, 2016 at 2:18 am #1162626You’re welcome.
-
AuthorPosts