Tagged: cornerstone
-
AuthorPosts
-
June 25, 2016 at 12:16 pm #1059362
Hello, I’m using WordPress 4.5.3 running X theme version 4.5.2 and Cornerstone 1.2.4 on the website I’m developing (http://fbb.bg).
I want to make some of the main menu options to link to certain tabs in the accordions (which was easy using # deep links) and then set it open. Setting the tab in an open state is what I still can’t figure out. Is it possible, at all?
By default most of these tab should be closed and I don’t want to set them open in advance, but I’d rather have everything closed but the one that the user is redirected to via the deep link.
Regards,
LyubozarJune 25, 2016 at 12:18 pm #1059363This reply has been marked as private.June 25, 2016 at 7:31 pm #1059577Hello There,
Thanks for writing in! To open the accordion section when your link is pointing to it, please add the following JS code in the customizer, Appearance > Customize > Custom > Javascript
(function($){ var pageAddress = window.location.hash; if ( pageAddress || pageAddress != '' ) { console.log(pageAddress); var navbar = $('.x-navbar').outerHeight(); var yloc = $(pageAddress).offset().top - 160; console.log($(pageAddress).offset().top); console.log('tab: ' + pageAddress + ', yloc: ' + yloc); $('.x-accordion-toggle[href^="' + pageAddress + '"').trigger('click'); $('html, body').animate({ scrollTop: yloc }, 850, 'easeInOutExpo'); } })(jQuery);
We would loved to know if this has work for you. Thank you.
June 26, 2016 at 7:45 am #1060052Hello,
Thanks for your reply!
I’ve added the script. Unfortunately, it’s not working.June 26, 2016 at 7:52 am #1060056When I use this script
jQuery(document).ready(function($) {
$(‘.open_accordion’).click(function(e) {var $this = $(this);
var thisHref = $this.attr(‘href’);
var accordion = $(thisHref).find(‘.x-accordion-toggle’);if ( accordion.length && $(thisHref).hasClass(‘x-accordion-group’) ) {
e.preventDefault();accordion.trigger(‘click’);
window.location.replace(thisHref);
}});
});I add this as a class to a button and then and then it is doing fine but not from the main menu items.
My aim is accordion tab opening to work from the main menu items.June 26, 2016 at 8:06 am #1060061Hi there,
Did you try to add
open_accordion
class to menu items?Thanks.
June 26, 2016 at 10:24 am #1060156June 26, 2016 at 4:28 pm #1060410Hi there,
When adding class to menu item, it applies to the
<li></li>
and not directly to the link.Change this,
$('.open_accordion')
to this,
$('.open_accordion a, a.open_accordion')
Hope that helps.
June 26, 2016 at 9:05 pm #1060730Oh yes,
Now it is ok! Thank you!June 26, 2016 at 10:44 pm #1060813You’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread. -
AuthorPosts