Hello everyone,
I've built a website using Astro and leveraged its View Transitions API. However, I've hit a snag. My Calendly button component isn't fully working.
The issue is during client-side navigation, where the essential script code fails to load. This causes the 'onclick' event to malfunction, preventing Calendly's pop-up widget from appearing.
I've experimented with the astro:page-load directive, but to no avail. It's possible I may have implemented it incorrectly, or it may not be the right solution.
Could you help me? Here's the code for my Calendly component:
// Calendly.astro
const onClick = Calendly.initPopupWidget({url: '${calendlyUrl}'});return false;;
<link href="https://assets.calendly.com/assets/external/widget.css" rel="stylesheet" />
<script src="https://assets.calendly.com/assets/external/widget.js" type="text/javascript" async></script>
<WidgetWrapper id={id} isDark={isDark} containerClass={max-w-5xl mx-auto ${classes?.container ?? ''}} bg={bg}>
<div
class="max-w-3xl mx-auto text-center p-6 rounded-md shadow-xl dark:shadow-none dark:border dark:border-slate-600"
<Headline
title={title}
subtitle={subtitle}
classes={{
container: 'mb-0 md:mb-0',
title: 'text-4xl md:text-4xl font-bold leading-tighter tracking-tighter mb-4 font-heading',
subtitle: 'text-xl text-muted dark:text-slate-400',
}}
/>
<div class="mt-6 max-w-xs mx-auto">
<a href="#" class="btn btn-primary w-full sm:w-auto" onclick={onClick}>
<Icon name="tabler:rocket" class="w-5 h-5 mr-1 -ml-1.5 rtl:-mr-1.5 rtl:ml-1" />
{buttonText}
</a>
</div>
</div>
</WidgetWrapper>
Website: https://venger.me/
P.S. If you could share a link or explain how to better embed the code, I'd appreciate it as well!