magnific popup not working

toothie picture toothie · Jan 17, 2014 · Viewed 22.6k times · Source

I am using Magnific Popup.

$(document).ready(function() {
  $('.image-viewer').magnificPopup({
      type: 'ajax'
  });
});

This is the html:

<a href="/site-media/{{ photo.image }}" class="image-viewer"><img class="fest-content-event-content-photo" width = "100%" src="/site-media/{{ photo.thumbnail2 }}" /></a>

But, it isn't working and the console shows error:

 Uncaught TypeError: Property '$' of object [object Object] is not a function (index):30
(anonymous function) (index):30
fire jquery.js:3048
self.fireWith jquery.js:3160
jQuery.extend.ready jquery.js:433
completed

What is wrong? I have not loaded tje jquery.js file twice.

Answer

Felix picture Felix · Jan 17, 2014

First, make sure you've included the jQuery library properly:

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

Secondly, maybe there is a conflict between jQuery with other libraries, you can try to use:

jQuery(document).ready(function ($) {
     $('.image-viewer').magnificPopup({
          type: 'ajax'
     });
});