Open content area off canvas with link works only once

Hey there,

Once we click on the anchor link, the content area opens, however after we close it, clicking again on the link won’t re-open the content area.

Anyway to fix this?

Thank you!

Hi @thisisbbc,

Thank you for reaching out to us. This is happening because of the hash links, if once added to the URL it prevents the content area to open again. To resolve the issue, add the following code in the Theme Options > JS:

jQuery(document).ready(function($){
	$('.x-off-canvas-close').click(function(){
		var url = window.location.href;
		url = url.split('#')[0];
		window.history.replaceState({}, document.title,  url);
	});
});

Don’t forget to clear all caches including your browser’s cache after adding the code. Let us know how this goes!

Thank you Nabeel!

The snippet worked perfectly.

All best,
B

Glad we could help.

Cheers!

Hey Nabeel,

It looks like I may have spoken too fast.

Your snippet works if the user clicks on the “Close” button on the upper-right of the off-canvas content area but if you just click outside of the area, effectively closing it, clicking again on the link won’t re-open the area.

Any fix for that?

Thank you!

Hi @thisisbc,

You can try adding the code below inCornerstone > JS

$( ".x-off-canvas-bg" ).on( "click", function() {
   $('.x-off-canvas-close').click();
});

Please add it together with the other code

jQuery(document).ready(function($){
	$('.x-off-canvas-close').click(function(){
		var url = window.location.href;
		url = url.split('#')[0];
		window.history.replaceState({}, document.title,  url);
	});

        $( ".x-off-canvas-bg" ).on( "click", function() {
              $('.x-off-canvas-close').click();
        });
});

Hope that helps

Hey Paul,

Thanks for the snippet, works PERFECTLY!

Have a great day ahead.

All best,
B

You’re wecome! :slight_smile:

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