Jump to content

Javascript only working on page reload SS 7.0

Recommended Posts

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>

Link to comment
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi DevonLois

Did you try to turn off ajax? I think the issue comes from the script not first again when you navigate to the page via ajax

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

Link to comment
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

Greeting, it's BeyondSpace, I am Squarespace dev focus on provide solutions to enhance feature that squarespace.com can't provide.
Feel free to check my current Squarespace Plugins Developement: Enable Pinch/Zoom on lightbox, Delivery Date Picker, Keyword Highlighter
If you find my answer fit your need, let's leave a like or upvote so others with the same issue can find their solution. Thank you

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.