This is possible as long as you have next and previous links within the page that you are pulling in via ajax.
This worked for me:
$('.js-pack').magnificPopup({
delegate: '.js-mfp-ajax',
type: 'ajax',
closeOnBgClick: false,
mainClass: 'mfp-fade',
removalDelay: 300,
overflowY: 'scroll',
gallery: {
enabled: true
},
callbacks: {
ajaxContentAdded: function() {
$('.prev-next .next-link').click(function(event){ event.preventDefault(); $.magnificPopup.next(); });
$('.prev-next .prev-link').click(function(event){ event.preventDefault(); $.magnificPopup.prev(); });
}
}
});
They key parts to add are gallery: enabled
and the callbacks
parameters.
The HTML of my next-prev buttons is pretty simple:
<div class="prev-next">
<a class="btn prev-link" href="http://prev-url" rel="prev">« Previous</a>
<a class="btn next-link" href="http://next-url" rel="next">Next »</a>
</div>