Jump to content

Collapsable FAQ on mobile

Recommended Posts

Site URL: https://carrot-bronze-bld8.squarespace.com/coop-curbside

Hello!

I was able to create a collapsible FAQ through a markdown block and the following code but the content does not collapse on mobile--any ideas how to resolve?

<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 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>

 

Thank you!

Link to comment
On 9/23/2021 at 6:01 PM, mackenzieu said:

I was able to create a collapsible FAQ through a markdown block and the following code but the content does not collapse on mobile--any ideas how to resolve?

It doesn't work because of a Brine feature called Ajax Page Loading - a fantastic feature that makes Brine sites load more quickly.

You may not realise this, but the FAQ does not work for desktop visitors either. This is because the Ajax page loading feature gets disabled when you're logged on to your site. This can give you a flase sense of security. It's always a good idea to open a site in an Incognito window (without logging on) when you are testing it.

To prevent the FAQ issues, you'll want to change the code placement (place it in a Code Block within the page above the FAQ) or disable Ajax Page Loading altogether - although this will slow down the site. See my guide here: Why does Squarespace code only work on refresh?

Also you (and other readers) may want to note that the code snippet you've used is very old and uses an old version of jQuery that has known security vulnerabilities. You'll want to use the up-to-date version (currently 3.6.1).

  If this post has helped you, please click an icon below  ⬇️

Edited by paul2009

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment
  • 4 weeks later...
11 hours ago, mackenzieu said:

it is still not collapsing on mobile

I'm not seeing that issue when I take a look.

345646824_Screenshot2021-10-19at12_10_18.thumb.png.8dc27e6e2763b83cb59895a21db7302e.png

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment
10 minutes ago, mackenzieu said:

When I test it on my iPhone it's not functioning correctly

It's difficult for me to troubleshoot as it's good for me on iPhone too. 

collapsed-accordion.thumb.jpeg.38421dc381f636ca6edc244ab354a2db.jpeg

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

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.