New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Magnific Popup with AJAX-loaded content #985
Comments
On document load initialize mp as normal:
In your ajax call, trigger the binding of magnific popup after the ajax content is loaded:
In your magnificPopup jQuery function:
|
use and then put your own selector (selector inside AJAX dom element) to
It works for me, no need to re initialize |
Thanks, it works. |
If I use delegate then how do I get clicked element? is there any way of getting the click event? |
thank you so much ! this works for me |
Hi,
I have some content that is loaded through AJAX. Magnific doesn't work with that content because the event listeners fire on page load, but the the AJAX-loaded content is not yet inserted in the page at that point.
The only workaround for this that I know of is to use inline javascript on the AJAX-loaded content. I tried to do something like:
<a class="test-popup-link" href="path-to-image.jpg" onclick="magnificPopup({type: 'image'}).magnificPopup('open');">Open popup</a>
But unfortunately it doesn't seem to work. I get
ReferenceError: magnificPopup is not defined
, even though the magnific-popup.js file is included in the page.Any help on how to get this to work would be appreciated. Thanks!
The text was updated successfully, but these errors were encountered: