Accordion open on button

Hi there
I’m trying to get a button click on a page to scroll down to a certain section of that same page and open the accordion.

This is the page in question: http://www.gilbertsondavis.com/ontario-arbitrators-mediators/

So if you click on the blue button in the hero banner “David Alderson, LL.B, LL.M, Q,Arb Hourly Rate: From $350 an hour* >” The accordion opens, but is no longer scrolling to that section.

The code I have implemented right now is this:

jQuery(document).ready(function($) {
$('.open_accordion.x-btn').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');
	}

});
var uri= window.location.href;
var result = uri.split("/").pop();
if (result.indexOf('#') >= 0) {
	setTimeout(function(){$('.open_accordion[href="' + result + '"]').trigger('click');}, 100);
}
});    

Can you help with any modification to this to have the scroll function come back?

Thanks alot.

Hi Xi,

Thank you for writing in, regretfully we can not provide support for any customization. Actually, you don’t need the custom script, there is a Toggle Hash option on the Accordion item element, which you can use to deep-link or bind with a Button element.

For example, your Toggle Hash is open-item2 , then your button URL should be #open-item2.

You also need to apply the #open-item2 as the ID of the Section containing your Accordion, so it will scroll down to that section.

I notice your version of X and Cornerstone are outdated, so your elements might not have these controls yet. You need to update to the latest version of X and Cornerstone.

Remember to clear all your caching features (plugin, server-side, CDN, and browser’s cache) after updating so that the code from the latest release is always in use. This will help you to avoid any potential errors.

Hope it helps,
Cheers!

Hi there
Thanks for the reply. Unfortunately, we can’t update X and Cornerstone at the moment without some other components of the website breaking. There is no Toggle Hash option in my current version on the accordion item for deep linking.

Is it possible at all for you to provide some support on the code? Thanks

Hi Xi,

You are using a much older version of the theme where the Accordion Items does not have that option. To get that option, you need to update the X theme and the Cornerstone.

I would suggest you please copy your live site to a staging server and update the theme to its latest version and if everything works fine, migrate the site to the lives server.
Updating the theme to its staging server will help you update it without breaking your live site.

Hope it helps.
Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.