Search code examples
javascriptjquerycallbackmagnific-popup

How to get the url on the magnific popup API on open event?


How can I get the url being opened with the Magnific popup API? I want to add it the window.location.hash in the open event callback:

<a href="page-title" class="mfp">Lorem ipsum</a>

$('.mfp').magnificPopup({

  callbacks: {
    open: function() {
     var url = this.url
     window.location.hash += '-'+url
    }
  }
});

I tried using this.url but no luck.


Solution

  • Found the answer:

    first, searched through console.log($.magnificPopup.instance) and finally found

    this.currItem.src