Jump to content

Trying to insert custom scripts on filtered view event pages

Recommended Posts

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

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, 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...

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.