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

use above code (code 2) 

+ add this to Code Injection Header

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

How to: Setup Password & Share url Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care

Link to comment
  • 2 years later...
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 best , and see my profile. Thanks for your support!

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.