When you call

$('.image-popup')

(with anything after the .) it will only apply to the elements that exist at that time. eg $('.image-popup').click(function() { alert("click"); }); will only put an event handler for those that exist so appending any new elements will not have that click handler (which is why we need to use event delegation for dynamically added elements).

The same applies here.

$('.image-popup').magnificPopup({

will tell magnificPopup only about the image-popups that exist at that time. When you add new ones later, it doesn't know about them.

So you need to recall your magnificPopup initialisation after you add the new elements.

Answer from freedomn-m on Stack Overflow
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 985
Use Magnific Popup with AJAX-loaded content · Issue #985 · dimsemenov/Magnific-Popup
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('ope...
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 794
Magnific-Popup not working after ajax sucess · Issue #794 · dimsemenov/Magnific-Popup
January 5, 2016 - I had a similar issue on a wordpress ... the AJAX had completed. jQuery(window).load(function(){ means you are trying to run MP on things which haven't loaded yet....
Discussions

jquery.magnific-popup not working when generated after ajax post
my problem is when i append to the div from jquery after ajax post the popup magnifier does not work at all i am using jquery.magnific-popup $(document).ready(function () { $('.image... More on stackoverflow.com
🌐 stackoverflow.com
March 8, 2018
Using magnific popup type ajax in form Submit
🌐 forum.jquery.com
Reload ajax magnific pop-up
$.magnificPopup.open({ items: {}, type: 'ajax', ajax: { settings: { url: some_url, cache:false, dataType: 'json', method: 'POST', data: params } }, key: 'basket_popup'}) ... C. GrahamC. Graham ... Is it better to redirect users who attempt to perform actions they can't yet... ... 2 Magnific Popup Not working properly when i try to call it on page load time or via onclick function · 2 Automatically close magnific Popup iframe after ... More on stackoverflow.com
🌐 stackoverflow.com
8 - Loading an Ajax form through Ajax (Magnific Popup) - Drupal Answers
I'm trying to load an Ajax form using the Magnific Popup Ajax type and as expected the returned Form is not Ajaxified as I need to attach behaviors to it. However, following other related issues d... More on drupal.stackexchange.com
🌐 drupal.stackexchange.com
June 14, 2017
🌐
Dimsemenov
dimsemenov.com › plugins › magnific-popup › documentation.html
Magnific Popup Documentation
Internationalization of Magnific Popup is very simple, all you need is to extend default settings object with new values, or just pass options to your initialization code. If you’re making some public plugin or theme, it’s strongly recommended ...
🌐
Stack Exchange
drupal.stackexchange.com › questions › 238389 › loading-an-ajax-form-through-ajax-magnific-popup
8 - Loading an Ajax form through Ajax (Magnific Popup) - Drupal Answers
June 14, 2017 - (function ($, Drupal) { 'use strict'; Drupal.behaviors.MemberPhotosGallery = { attach: function (context, settings) { $(window).on('hashchange', function () { var url = window.location.hash.substring(1); if (url == '/' || url == '') { $.magnificPopup.close(); } else if (url.substring(0, 6) == "/photo") { $.magnificPopup.open({ items: { src: url }, type: 'ajax', mainClass: 'mfp-zoom-out', showCloseBtn: true, closeOnBgClick: false, callbacks: { close: function () { window.location.hash = '/'; }, ajaxContentAdded: function () { var form = $('form#member-photo-edit')[0]; Drupal.attachBehaviors(form, settings); //# Triggering this doesn't ajaxify the Form.
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 406
Specific content loaded via Ajax not working · Issue #406 · dimsemenov/Magnific-Popup
March 17, 2014 - I'm trying to load the content of a specific div of an external html file via "ajax", but I don't understand how to make it work. Here is what I'm doing: $(document).ready(function() { $('.n_link').magnificPopup({ type: 'ajax', modal: true, gallery:{enabled:true}, callbacks: { parseAjax: function(mfpResponse) { mfpResponse.data = $(mfpResponse.data).find('#pip'); console.log('Ajax content loaded:', mfpResponse); }, ajaxContentAdded: function() { console.log(this.content); } } }); });
Author   Animalejourbano
Find elsewhere
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 526
Opening popup from ajax loaded popup close both · Issue #526 · dimsemenov/Magnific-Popup
August 8, 2014 - Hello, here is a workaround for your problem. $("#myButton").click(function() { // close current Popup $.magnificPopup.close(); // 100, time must be bigger, as the delay from the first popup. By me the delay is 65 window.setTimeout(openNewAjaxPopup,100); }); // open the new ajax popup function openNewAjaxPopup() { $.magnificPopup.open({ closeOnBgClick: false, closeBtnInside: true, enableEscapeKey: true, removalDelay: 65, mainClass: 'mfp-fade', items: { }, callbacks: { elementParse: function(item) { postData = { data: data, } var mp = $.magnificPopup.instance; mp.st.ajax.settings.data = postData; } }, type: 'ajax', ajax: { settings: { url: './ajax/page,html', type: 'POST' } } }); } Sign up for free to join this conversation on GitHub.
🌐
Stack Overflow
stackoverflow.com › questions › 47473705 › magnific-popup-not-working
javascript - Magnific-Popup Not Working
It seems that you have included both: <script src="magnific-popup/jquery.magnific-popup.js"></script> <script src="magnific-popup/jquery.magnific-popup.min.js"></script> ... replace this block of code in your code.
🌐
Stack Overflow
stackoverflow.com › questions › 30533740 › magnific-popup-jquery-ajax-popup-is-not-working
Magnific Popup Jquery: Ajax Popup is not working
May 29, 2015 - <script type="text/javascript"> $(document).ready(function() { $('.ajax').magnificPopup({ delegate: 'a', type: 'ajax', alignTop: true, overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump } } }); }); </script>
🌐
GitHub
github.com › dimsemenov › Magnific-Popup › issues › 1107
magnific popup ajax stopped when scrolling · Issue #1107 · dimsemenov/Magnific-Popup
January 26, 2019 - $(document).ready(function() { var ias = $.ias({ container: "#switchview", item: "article.post", pagination: ".posts-navigation", next: ".nav-previous a" }); var inumber = mainscript.infinitenumber; ias.extension(new IASSpinnerExtension({ html: '<div class="switch-loader"><span class="loader"></span></div>' // override text when no pages left })); // shows a spinner (a.k.a. loader) ias.extension(new IASTriggerExtension({offset: inumber})); // shows a trigger after page 3 ias.extension(new IASNoneLeftExtension({ html: '<div class="load-nomore"><span>There are no more pages left to load.</span></div>' // override text when no pages left })); }); ... $('.ajax-popup-link').magnificPopup({ type: 'ajax', callbacks: { parseAjax: function(mfpResponse) { mfpResponse.data = $(mfpResponse.data).find('.entry-content, .post-video'); console.log('Ajax content loaded:', mfpResponse); } } });
🌐
Stack Overflow
stackoverflow.com › questions › 30276381 › magnific-popup-re-initiate-on-ajax-content
magnific-popup - re-initiate on ajax content - Stack Overflow
$( '.client-logo-overlay' ).magnificPopup({ //modal: true, //closeBtnInside:true, //closeOnBgClick: true, //showCloseBtn: true, delegate: 'a', type: 'ajax', ajax: { settings: { url: $( this ).attr( 'href' ), type: 'POST' } }, callbacks: { parseAjax: function( mfpResponse ) { var html = $( mfpResponse.data ).find( 'article' ); mfpResponse.data = $( '<div>', { class: 'white-popup small' } ).append( html ); } } }); However, when loading some content using AJAX, MagnificPopup doesn't work anymore on those newly inserted elements - what am I missing.