Jump to content

Make whole summary item div clickable

Go to solution Solved by tuanphan,

Recommended Posts

Site URL: https://www.susanchalkermassage.com/

Hi Circle,

I want to make my whole summary item div clickable. You'll see on the website its the summary items under modalities. (summery item png attached)

I have tried the following

<script>
  Y.on('domready', function(){
Y.one('.sqs-block-summary-v2 .summary-item').on('click', function(e){
  window.location = $(this).find("a").attr("href"); 
  return false;
});
</script>

and this

$(".summary-item").click(function() {
  window.location = $(this).find("a").attr("href"); 
  return false;
});

nothing is happening!

Thanks for reading. 

summary item.png

Link to comment
  • 2 years later...
2 hours ago, dnmddy said:

I've tried that code but it isnt working for me. What am I doing wrong?

The code won't work with Lazy Summaries. When the code runs that are no summary items on the page yet.

You need to use LS's Advanced options to do what you want. It is not easy.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
1 minute ago, creedon said:

The code won't work with Lazy Summaries. When the code runs that are no summary items on the page yet.

You need to use LS's Advanced options to do what you want. It is not easy.

Ah, that makes sense. Thanks for pointing that out. 

Re: "It is not easy"... yeah, that advanced section is over my head!

Link to comment
4 hours ago, dnmddy said:

I just deactivated Lazy Summaries on that block and it's still not working.

I suspect then that how summary blocks are loaded changed from  over two years ago when the code was written. Back then they probably loaded them when the page loaded. Now they probably load them lazily to be more performant.

I don't recall how they used to be loaded vs how they are now loaded. I'm usually dealing with how things work now and sometimes forget how they used to work! 🙂 Perhaps someone can edify us just for grins.

When things are lazily loaded (and not using lazy summaries) one needs to use a Mutation Observer. It is a way to watch for things to come onto the DOM. It is also not easy to code MO's.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

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.