metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.5k stars 604 forks source link

What do I do to have flickity as jQuery plugin. #1257

Closed ghost closed 1 year ago

ghost commented 1 year ago

I have jquery as jQuery, not $ Also I am using it inside Drupal behaviors. I installed it as yarn package. import Flickity from "flickity";

In the end of day I get Uncaught TypeError: jQuery(...).flickity is not a function

sadeghbarati commented 1 year ago

We don't know what is your project structure looks like and what tool you using besides Drupal for importing modules from node_modules

So just a tip

import $ from 'jquery'
Object.assign(window, { $: jQuery, jQuery })

console.log(window) // window Object

// or put your code inside
window.addEventListener('load', () => {
   //...
})

make sure jQuery or $ and Flickity is available in the window Object