sebastianadams Posted December 11, 2021 Share Posted December 11, 2021 (edited) I've been working on custom code to programmatically populate a list of works page from a Firestore database. In VSCode/localhost everything works perfectly, but I am trying to add event listeners to every element in a class (downloadScore) and when the code is running on squarespace those event listeners don't work. As other event listeners I create in a similar manner do work, and because it works in localhost (without Squarespace page around it), I am thinking it might be an interaction between my code and the squarespace code. I'm wondering if anybody else has hit this problem or a similar one when injecting event listeners? My page is a 7.0 Wells site, there's no option to turn off AJAX in styles, and I have tried using a script I found on the forum to turn that off too, it seemed to make no difference. Update: I solved the problem myself. It was a combination of two things - I needed to chain a then to the promise made by the Firestore function to ensure the eventlisteners didn't run too early, and there was an undefined variable (actually probably caused by another bug in my code...) breaking the Firestore promise early. I think...not an expert at all....but hoping this could be helpful to nudge anybody else in the righr direction. Edited December 11, 2021 by sebastianadams Solved myself Beyondspace 1 Link to comment
Beyondspace Posted December 12, 2021 Share Posted December 12, 2021 12 hours ago, sebastianadams said: I've been working on custom code to programmatically populate a list of works page from a Firestore database. In VSCode/localhost everything works perfectly, but I am trying to add event listeners to every element in a class (downloadScore) and when the code is running on squarespace those event listeners don't work. As other event listeners I create in a similar manner do work, and because it works in localhost (without Squarespace page around it), I am thinking it might be an interaction between my code and the squarespace code. I'm wondering if anybody else has hit this problem or a similar one when injecting event listeners? My page is a 7.0 Wells site, there's no option to turn off AJAX in styles, and I have tried using a script I found on the forum to turn that off too, it seemed to make no difference. Update: I solved the problem myself. It was a combination of two things - I needed to chain a then to the promise made by the Firestore function to ensure the eventlisteners didn't run too early, and there was an undefined variable (actually probably caused by another bug in my code...) breaking the Firestore promise early. I think...not an expert at all....but hoping this could be helpful to nudge anybody else in the righr direction. It should be better if you can share your site with the protected password so we can take a look BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox - Lightbox captions only mode) 🗓️ Delivery Date Picker (Squarespace Date picker form field) 💫 Gallery block 7.1 workaround 🥳 No-code customisations for Squarespace 🚀 Learn how to rank new pages on Google in 48 hours! 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment