sachinchoolur / lightGallery

A customizable, modular, responsive, lightbox gallery plugin.
https://www.lightgalleryjs.com/
Other
6.55k stars 1.29k forks source link

$(...).lightGallery is not a function #931

Closed tuzibixia closed 3 years ago

tuzibixia commented 4 years ago

Describe the bug Sorry! I already know this errorMsg is not a bug, but I want to know If the old site has more than 1 jQuery version there. Though I can't touch that I still want to use this beautiful framework, how can I do with it.

To Reproduce Steps to reproduce the behavior:

  1. The demo is working so well at local .
  2. Move the demo code online because of jQs there is a error msg: $(...).lightGallery is not a function.And the framework doesn't work.

Expected behavior I want to use lightGallery under different jQuery versions, can I choose which jQ version the lightGallery function is bund by ?

Screenshots

截屏2020-04-2219 23 13

Desktop (please complete the following information):

otherjohn commented 4 years ago

I am getting the same error. I was following directions on using lightgallery with lightslider. jquery version: "3.4.1" my code:

require('lightslider')
require('lightgallery')
...

$('#imageGallery').lightSlider({
            gallery:false,
            item:4,
            loop:true,
            thumbItem:9,
            slideMargin:0,
            enableDrag: false,
            currentPagerPosition:'left',
            onSliderLoad: function(el) {
                el.lightGallery({
                    selector: '#imageGallery .lslide'
                });
            }
        });
otherjohn commented 4 years ago

UPDATE: when included the src/js/lightgallery.js file, it worked. I should add, that I am using webpack.

sdzhurova commented 4 years ago

I am currently having the same issue:

$(…).lightGallery is not a function

Using the lightGallery inside a vue.js project like so:

  1. Inside app.js:
    
    import {ImageGallery} from './image_gallery';

require('lightgallery/dist/js/lightgallery.js'); // require('lightgallery'); // also tried this

class App { constructor() { this.imageGallery = new ImageGallery(); } }


2. Inside _image_gallery.js_:

... initLightgallery(container) { let $lg = $(container); $lg.lightGallery({ selector: 'figure.lightbox-trigger', mode: 'lg-fade', download: false, speed: 500, subHtmlSelectorRelative: true }); }



**Additional information:**

- Node: v12.13.1
- Npm: 6.13.7
- jQuery: 3.4.1
- Bootstrap: 4.3.1
- OS: Windows 10
- Browser: Chrome
bevbomb commented 4 years ago

I'm getting the same issue. Injected straight into a custom Wordpress plugin using cdnjs.com links. It works perfect on jQuery 1.12.4 but fails to load on jQuery 3.4.1

mitkovalkov commented 3 years ago

I have the same issue and I fixed it like this way import 'lightgallery';

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. If the issue is still valid for version 2.x, please re-open. Apologize for not responding on time. Thank you for your contributions.