javascript - Magnific Popup object -


magnific popup

i use magnific popup, jquery lightbox plugin. try use built in object attribute.

it not work way thought would. i've read api here:

http://dimsemenov.com/plugins/magnific-popup/documentation.html#api

what tried far

i object in console can't attribute it. (the jquery ready looks bit different (alias) because it's used in wordpress)

<script> jquery(document).ready(function($) {     $('.image-link').magnificpopup({         type:'image',             callbacks: {                 open: function() {                     var magnificpopup = $.magnificpopup.instance;                     console.log(magnificpopup.curritem);                     window.location.hash = $(magnificpopup.curritem).attr('data-slug');                     }             }     }); }); </script> <a href="http://www.someimage.com/image.png" data-slug="my-slug"> 

own thougts

  • this not object $(this) , not work same?
  • i call wrong way?
  • i use wrong object problem?

question

how done correctly?

curritem magnific popup data object, it's not dom element. object contains data opened element - image path, flags if it's loaded or not e.t.c.

you can access dom element opened popup via $.magnificpopup.instance.curritem.el.

also, if you're executing code open callback, can use this instead of $.magnificpopup.instance:

this.curritem.el 

Comments