Jump to content

Accordion blocks are no longer responding

Go to solution Solved by jpeter,

Recommended Posts

Hello!

I've just gone live on a website to find the accordion blocks that were working perfectly before have now stopping working.
Typical...! 

I don't suppose anyone else has the same issue? I don't think it's anything to do with going live, but client is keen for this to be fixed asap.

Thank you!

Link to comment

Can you share the website URL and page?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 

  Did I help? Buy me a coffee?

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

Link to comment
1 hour ago, Ziggy said:

Can you share the website URL and page?

Apologies, I added the website URL in the form but it hasn't shown!
It's www.porta-bowl.co.uk, home page right at the bottom.

I also have another on the product page (only one product) - both have stopped working.

Link to comment

Thanks, do you have any code or CSS on the website?

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 

  Did I help? Buy me a coffee?

🔌 Ghost Squarespace Plugins (Referral link)
📈 SEO Space (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲 SQSP Themes (Referral link) 
Spark Plugin (Referral link) 

Link to comment

@lauren-offpaper The issue is the JavaScript code that you have running that superscripts the registration mark is removing the JavaScript events attached to the accordion. Replace the JavaScript that superscripts the registration mark with the new JS below:

New JavaScript

/* superscripting all ® which aren't already */
window.addEventListener("DOMContentLoaded", function () {
  document.querySelectorAll("p, a, h1, h2, h3, h4, h5, h6, label").forEach(function (el) {
    const isAccordionItem = el.closest('.accordion-item__title-wrapper') !== null;
    const accordionTitleEl = isAccordionItem && el.querySelector('.accordion-item__title');
    if (accordionTitleEl) {
      accordionTitleEl.innerHTML = accordionTitleEl.innerHTML.replace(/®(?!\<\/sup)/g, "<sup>®</sup>");
    } else {
      el.innerHTML = el.innerHTML.replace(/®(?!\<\/sup)/g, "<sup>®</sup>");
    }
  })
});


Screenshot of the old/current JS:
image.thumb.png.1961d7f351ca2e211ac1abfeab3dec2f.png

Edited by jpeter

Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee!

Link to comment
14 hours ago, jpeter said:

@lauren-offpaper The issue is the JavaScript code that you have running that superscripts the registration mark is removing the JavaScript events attached to the accordion. Replace the JavaScript that superscripts the registration mark with the new JS below:

New JavaScript

/* superscripting all ® which aren't already */
window.addEventListener("DOMContentLoaded", function () {
  document.querySelectorAll("p, a, h1, h2, h3, h4, h5, h6, label").forEach(function (el) {
    const isAccordionItem = el.closest('.accordion-item__title-wrapper') !== null;
    const accordionTitleEl = isAccordionItem && el.querySelector('.accordion-item__title');
    if (accordionTitleEl) {
      accordionTitleEl.innerHTML = accordionTitleEl.innerHTML.replace(/®(?!\<\/sup)/g, "<sup>®</sup>");
    } else {
      el.innerHTML = el.innerHTML.replace(/®(?!\<\/sup)/g, "<sup>®</sup>");
    }
  })
});


Screenshot of the old/current JS:
image.thumb.png.1961d7f351ca2e211ac1abfeab3dec2f.png

Incredible, thank you - solved instantly!
I didn't think superscript would affect it so much haha, thanks so much!

I originally had the code injection in the footer but it's now viewable on the page.

I've moved it to the header instead but it's briefly visible when you load the page - is there any way to hide this?

Edited by lauren-offpaper
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.