Skip to content

[Help]: How to use plugins when initializing Embla using Alpine JS #902

Closed Answered by davidjerleke
MikeHarrison asked this question in Help
Discussion options

You must be logged in to vote

Hi @MikeHarrison,

I don't know anything about how AlpineJs works, but following your current setup I got it working like this:

import EmblaCarousel from "https://esm.sh/embla-carousel";
import EmblaCarouselAutoplay from "https://esm.sh/embla-carousel-autoplay"; // <-- Add this
import Alpine from "https://esm.sh/alpinejs";

window.EmblaCarousel = EmblaCarousel;
window.EmblaCarouselAutoplay = EmblaCarouselAutoplay;  // <-- Add this

window.Alpine = Alpine;
Alpine.start(); 

And your HTML:

<div class="py-6 bg-gray-50 rounded-lg border-gray-300 border shadow-inner"
    x-data="{embla: null, activeSlide: 0}"
    x-init="() => {
      embla = EmblaCarousel($refs.viewport, {loop: true}, [EmblaCar…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by davidjerleke
Comment options

You must be logged in to vote
1 reply
@davidjerleke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something alpine Issue is related to AlpineJS
2 participants