Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: $(...).lightGallery is not a function

when I try to click the link it shows this in browser console:

Uncaught TypeError: $(...).lightGallery is not a    function(anonymous function) @ index.html:250dispatch @ jquery.min.js:3r.handle @ jquery.min.js:3

and this is the code I used:

    $('#gallery').on('click', function() {
    $(this).lightGallery({
        dynamic: true,
        dynamicEl: [{
            "src": 'assets/images/gallery/1.jpg',
            'thumb': 'assets/images/gallery/thumbs/1.jpg',
            'subHtml': '<h4>Fading Light</h4><p>Classic view from Rigwood Jetty on Coniston Water an old archive shot similar to an old post but a little later on.</p>'
        }, {
            'src': 'assets/images/gallery/2.jpg',
            'thumb': 'assets/images/gallery/thumbs/2.jpg',
            'subHtml': "<h4>Bowness Bay</h4><p>A beautiful Sunrise this morning taken En-route to Keswick not one as planned but I'm extremely happy I was passing the right place at the right time....</p>"
        }, {
            'src': 'assets/images/gallery/3.jpg',
            'thumb': 'assets/images/gallery/thumbs/3.jpg',
            'subHtml': "<h4>Coniston Calmness</h4><p>Beautiful morning</p>"
        }]
    })
});

bear in mind I am using the Dynamic Mode in lightGallery.

  1. I already included the lightGallery library before and the jQuery library before it.
  2. I have tried to substitute the $ with jQuery.
  3. I also tried the "semicolon solution" but with no luck.

this is the whole libraries i included:

    <script src="assets/web/assets/jquery/jquery.min.js"></script>
  <script src="assets/tether/tether.min.js"></script>
  <script src="assets/bootstrap/js/bootstrap.min.js"></script>
  <script src="assets/smooth-scroll/SmoothScroll.js"></script>
  <script src="assets/viewportChecker/jquery.viewportchecker.js"></script>
  <script src="assets/cookies-alert-plugin/cookies-alert-core.js"></script>
  <script src="assets/cookies-alert-plugin/cookies-alert-script.js"></script>
  <script src="assets/dropdown/js/script.min.js"></script>
  <script src="assets/touchSwipe/jquery.touchSwipe.min.js"></script>
  <script src="assets/jarallax/jarallax.js"></script>
  <script src="assets/bootstrap-carousel-swipe/bootstrap-carousel-swipe.js"></script>
  <script src="assets/jquery-mb-ytplayer/jquery.mb.YTPlayer.min.js"></script>
  <script src="assets/theme/js/script.js"></script>
  <script src="assets/mobirise-slider-video/script.js"></script>
  <script src="assets/formoid/formoid.min.js"></script>
  <!-- lightgallery -->
  <script src="assets/theme/js/lightgallery.min.js"></script>
  <script src="assets/theme/js/lg-thumbnail.min.js"></script>
  <script src="assets/theme/js/lg-fullscreen.min.js"></script>
  <script src="assets/theme/js/lg-share.min.js"></script>
  <script src="assets/theme/js/lg-zoom.min.js"></script>
  <script src="assets/theme/js/lg-autoplay.min.js"></script>
like image 324
Hamza Abdullah Mohammed Avatar asked Sep 23 '16 16:09

Hamza Abdullah Mohammed


1 Answers

Wooooooooooo Haaaaaa I finally solved it, and the problem was maybe with local version I have!! When I switched to the cdnjs version it worked PERFECT!!! a huge THANKS for all of you!! all I did is replace the local ones with the cdn links

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/css/lightgallery.css" />

<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.3.2/js/lightgallery.js"></script>
like image 127
Hamza Abdullah Mohammed Avatar answered Sep 22 '22 11:09

Hamza Abdullah Mohammed