Jump to content

Collapsable FAQ on mobile

Recommended Posts

Posted

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!

  • Replies 6
  • Views 711
  • Created
  • Last Reply
Posted
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  ⬇️

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

  • 4 weeks later...
Posted
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

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Posted

Hmm... When I test it on my iPhone it's not functioning correctly and it looks like the screenshot below, but when I go to mobile width on desktop it collapses correctly. 

IMG_2894.jpg

Posted
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

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Posted

Wow that's so bizarre. I tested on some other devices and it's working fine there too! Thank you so much for your help--must be something wonky with my phone.  🙂

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.