Tagged: cornerstone
-
AuthorPosts
-
June 25, 2016 at 12:16 pm #1059362
lyubozarParticipantHello, 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 #1059363
lyubozarParticipantThis reply has been marked as private.June 25, 2016 at 7:31 pm #1059577
Rue NelModeratorHello 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 #1060052
lyubozarParticipantHello,
Thanks for your reply!
I’ve added the script. Unfortunately, it’s not working.June 26, 2016 at 7:52 am #1060056
lyubozarParticipantWhen 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 #1060061
ChristopherModeratorHi there,
Did you try to add
open_accordionclass to menu items?Thanks.
June 26, 2016 at 10:24 am #1060156
lyubozarParticipantOf course. This way:
June 26, 2016 at 4:28 pm #1060410
RadModeratorHi 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 #1060730
lyubozarParticipantOh yes,
Now it is ok! Thank you!June 26, 2016 at 10:44 pm #1060813
Rue NelModeratorYou’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
- <script> jQuery(function($){ $("#no-reply-1059362 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
