Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Trying to insert custom scripts on filtered view event pages


LFyel101

Question

Hi folks, wondering if anyone can help.

I'm trying to use javascript to add some custom code to a filtered view of events on squarespace (so a filtered view of a category).

(what i'm trying to do eventually is to add in some extra links above the "filtering by" text. )

966937274_Screenshot2021-06-30at13_56_30.thumb.png.dcbcf8d57fe3c414a4dc7dc4bc407102.png

 

I thought i'd do an initial test to see if I could get some code applied to the page (i.e just changing the background colour of the block). 

But it seems like something is happening when I try to apply the code to this page.  My code is super simple (see below)...

<script>
const filteredView = document.querySelectorAll("div.sqs-events-collection-list")
  
filteredView.style.backgroundColor = '#000000'
  
</script>

However, when I check the console, everything I try to set just keeps coming up as "undefined". 1851403206_Screenshot2021-06-30at11_30_57.png.d89ac8dc76c318957bf1e700c0855944.png

 

Does anyone know if there's something that blocks scripts on category pages? or perhaps there's something i'm missing!

 

i've tried adding the script to both the footer and header injection...

 

 

 

any help or advice appreciated!

Edited by LauraF101
Link to comment

1 answer to this question

Recommended Posts

  • 0
12 hours ago, LauraF101 said:

Hi folks, wondering if anyone can help.

I'm trying to use javascript to add some custom code to a filtered view of events on squarespace (so a filtered view of a category).

(what i'm trying to do eventually is to add in some extra links above the "filtering by" text. )

966937274_Screenshot2021-06-30at13_56_30.thumb.png.dcbcf8d57fe3c414a4dc7dc4bc407102.png

 

I thought i'd do an initial test to see if I could get some code applied to the page (i.e just changing the background colour of the block). 

But it seems like something is happening when I try to apply the code to this page.  My code is super simple (see below)...

<script>
const filteredView = document.querySelectorAll("div.sqs-events-collection-list")
  
filteredView.style.backgroundColor = '#000000'
  
</script>

However, when I check the console, everything I try to set just keeps coming up as "undefined". 1851403206_Screenshot2021-06-30at11_30_57.png.d89ac8dc76c318957bf1e700c0855944.png

 

Does anyone know if there's something that blocks scripts on category pages? or perhaps there's something i'm missing!

 

i've tried adding the script to both the footer and header injection... 

 

site URL https://ellipse-krill-97td.squarespace.com/programme?category=Event and pw: CG

 

any help or advice appreciated!

You used querySelectorAll, it return a list of element, use querySelector instead

Greeting, it's BaNgan from 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, Portfolio hover Replace Link Style
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...