siaeva Posted July 27, 2021 Share Posted July 27, 2021 Site URL: https://brine-demo.squarespace.com/How would you rewrite this script so it works despite the Ajax loading on the Brine template? Right now it only works if you refresh the page. <script> $(document).ready(function(){ $('.markdown-block .sqs-block-content h3').css('cursor','pointer'); $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideToggle(); $(".markdown-block .sqs-block-content h3").click(function() {$(this).nextUntil("h3").slideToggle();}); }); </script> Beyondspace 1 Link to comment
Beyondspace Posted July 28, 2021 Share Posted July 28, 2021 6 hours ago, siaeva said: Site URL: https://brine-demo.squarespace.com/ How would you rewrite this script so it works despite the Ajax loading on the Brine template? Right now it only works if you refresh the page. <script> $(document).ready(function(){ $('.markdown-block .sqs-block-content h3').css('cursor','pointer'); $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideToggle(); $(".markdown-block .sqs-block-content h3").click(function() {$(this).nextUntil("h3").slideToggle();}); }); </script> try <script> $(document).ready(function(){ accordionTrigger(); }); window.addEventListener('mercury:load', accordionTrigger); function accordionTrigger(){ $('.markdown-block .sqs-block-content h3').css('cursor','pointer'); $(".markdown-block .sqs-block-content h3").nextUntil("h3").slideToggle(); $(".markdown-block .sqs-block-content h3").click(function() {$(this).nextUntil("h3").slideToggle();}); } </script> BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment