Jump to content

Javascript only working on page reload SS 7.0

Recommended Posts

Posted

Site URL: https://www.freeformgroup.org/phoenix-rising-1

I have a markdown accordion on my site that only works after the page is reloaded. Is this an ajax problem?

Here is the javascript I'm using that has worked fine on other sites:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
    $(document).ready(function(){
    $('.markdown-block .sqs-block-content h2').css('cursor','pointer');
    $(".markdown-block .sqs-block-content h2").nextUntil("h2").slideToggle();
    $(".markdown-block .sqs-block-content h2").click(function() {$(this).nextUntil("h2").slideToggle();});
    });
    </script>

  • Replies 2
  • Views 1.4k
  • Created
  • Last Reply
Posted
20 minutes ago, DevonLois said:

Site URL: https://www.freeformgroup.org/phoenix-rising-1

I have a markdown accordion on my site that only works after the page is reloaded. Is this an ajax problem?

Here is the javascript I'm using that has worked fine on other sites:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
    $(document).ready(function(){
    $('.markdown-block .sqs-block-content h2').css('cursor','pointer');
    $(".markdown-block .sqs-block-content h2").nextUntil("h2").slideToggle();
    $(".markdown-block .sqs-block-content h2").click(function() {$(this).nextUntil("h2").slideToggle();});
    });
    </script>

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
    $(document).ready(function() {
      window.addEventListener('mercury:load', function() {
      	$('.markdown-block .sqs-block-content h2').css('cursor','pointer');
    	$(".markdown-block .sqs-block-content h2").nextUntil("h2").slideToggle();
    	$(".markdown-block .sqs-block-content h2").click(function() {$(this).nextUntil("h2").slideToggle();});
      });    	
    });
</script>

Reference: https://stackoverflow.com/questions/47509602/squarespace-ajax-loading-do-not-display-custom-code

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.