Blog, Website & Page Publishing

DGrape74
Participant

Alpine JS carousel errors

Résolue

Has anyone tried to include a custom made carousel using alpine js? I have built one that works fine outside of hubspot but when I try to add it to a hubspot page it just says index is not defined, item is not defined etc... I have deferred the script loading and have tried it in the header and footer but nothing works.

 

Thanks

0 Votes
1 Solution acceptée
DGrape74
Solution
Participant

Alpine JS carousel errors

Résolue

Thanks for the tips. I was trying to do too much with the text editor. Pulling everything out into its own module fixed the issue. 

Voir la solution dans l'envoi d'origine

0 Votes
3 Réponses
Dani621
Membre

Alpine JS carousel errors

Résolue

The issue likely stems from how HubSpot handles script loading and variable scope. Ensure Alpine.js initializes after the DOM is fully loaded (e.g., wrap it in a DOMContentLoaded listener). If adding it to a blog page, verify that HubSpot allows custom scripts in the blog template. Scope issues, like index or item not being defined, may occur due to sandboxing—make sure they’re declared within your Alpine.js component. If problems persist, check HubSpot’s developer docs for script integration tips.

0 Votes
Jennie1
Membre

Alpine JS carousel errors

Résolue

I've run into similar issues with Alpine.js on HubSpot. Sometimes, HubSpot’s modules and inline JavaScript can conflict with Alpine’s reactivity. Here are a few things you could try:

  1. Ensure Alpine.js Loads Correctly: Make sure Alpine.js is loaded after HubSpot’s JavaScript to prevent any conflicts. Try adding the script right before the closing </body> tag to be certain it loads last.

  2. Scope Your Variables: HubSpot can sometimes isolate scopes, which may be why index and item aren’t recognized. Try explicitly defining these in your Alpine.js component or use Alpine’s x-init to define them when the component initializes.

  3. Console Check: Check the console for any specific errors related to HubSpot or other JavaScript libraries that may be overriding Alpine’s reactivity.

For more tech resources, you can also check Spotify Premium Apk. Let me know if this helps or if you’ve found a workaround!

0 Votes
DGrape74
Solution
Participant

Alpine JS carousel errors

Résolue

Thanks for the tips. I was trying to do too much with the text editor. Pulling everything out into its own module fixed the issue. 

0 Votes