Tagged: x
-
AuthorPosts
-
January 31, 2017 at 3:38 am #1352002
krealinersParticipantHi, I would like to open accordion elements not only clicking on it, but also using a menu link.
In this page http://www.lifefranca.eu/it/progetto/ you can see an accordion and in correspondance of menu voice PROGETTO the sub-voice linked with every accordion element. At thi moment they are a simple anchor to accordion elements.
How can I achieve to open directly accordion elements when clickin on PROGETTO sub menu?
Thanks in advance
January 31, 2017 at 7:55 am #1352235
JoaoModeratorHi There,
Please follow this thread:
https://community.theme.co/forums/topic/accordion-external-link/
Let us know how it goes,
Thanks
February 1, 2017 at 3:05 am #1353365
krealinersParticipantHi, I’ve read this thread and I try to apply the customizations to my website.
I’ve put inside Appearance > Customizer > Custom > Javascript the two following piece of code:
jQuery ( function ( $ ) {
var hash = window.location.href.split(‘#’)[1];
if ( hash !== undefined && $(‘.page-id-72 a[href^=”#collapse”]’).length > 0 ) {
$(document).ready ( function() {
$( ‘a[href^=”#’ + hash + ‘”]’ ).trigger(‘click’);
} );
}
} );
and then
(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);
But the accordion sections doesn’t open.
Can you check and tell if I’m wrong in some passage.
Thank you so much
February 1, 2017 at 4:49 am #1353450
LelyModeratorHi There,
Please try using the following code instead:
jQuery( function( $ ) { $( document ).ready ( function() { if(window.location.hash){ var target_tab = window.location.hash; if(target_tab!=''){ $( target_tab +' .x-accordion-heading>a').click(); } } $('.open-accordion-btn a').click(function(){ var target_tab = $(this).attr('href').split("#").slice(-1)[0]; $( '#'+target_tab +' .x-accordion-heading>a').click(); }); }); });Then on Appearance > menu > Submenu Link > Add open-accordion-btn on the CSS classes button. See attached screen shot.
Hope this helps.
February 1, 2017 at 6:53 am #1353591
krealinersParticipantThanks very much, now it’s working!
February 1, 2017 at 7:33 am #1353634
LelyModeratorYou’re welcome!
Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1352002 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
