If you're talkin bout the jquery accordion:
This also has been asked and solved in the german forum https://community.contao.org/de/show...l=1#post388650
In general we manualy open an accordion with the index of the targeted accordion starting by 0.
PHP Code:
$(document).accordion('option', 'active', 3); // 3 is the index of our accordion here
Here is my j_accordion-mod template you can try to use.
PHP Code:
//...snip
// original j_accordion Contao 3.5.15 above
/**
* open appropriate accordion if link hash target matches an accordion ID
* or an element ID within an accordion
*/
var
myAccordions = $('.toggler'),
closestAccordion = $(document.location.hash).closest('.ce_accordion').find('.toggler')
;
// open appropriate accordion if hash is in page URL and hash matches ID
if(closestAccordion.length) {
$(document).accordion('option', 'active', myAccordions.index(closestAccordion));
}
// all anchors
$('a').each(function() {
var hash = $(this).prop('hash');
// all anchors with a hash
if(hash) {
// search for an accordion with id=hash or including an element with id=hash
var closestAccordion = $(hash).closest('.ce_accordion').find('.toggler');
// click event for all affected anchors
if(closestAccordion.length) {
$(this).click(function() {
// open the appropriate accordion
$(document).accordion('option', 'active', myAccordions.index(closestAccordion));
});
}
}
});
// original j_accordion Contao 3.5.15 below
});
})(jQuery);
</script>
Bookmarks