A
A
advancess2020-07-15 00:48:43
AJAX
advancess, 2020-07-15 00:48:43

How to re-initiate Fotoram after loading ajax content?

Hello, photo frame is not working after ajax load. As I understand it, you need to re-initiate the photo frame. Tell me how

I call the photo frame like this ^

(function () {
  $('.fotorama').fotorama();
 })


ajax content like this
$('.popup-with-form').magnificPopup({
 	type: 'ajax'
  
 });

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Khegay, 2020-07-15
@advancesses

Try like this:

$('.popup-with-form').magnificPopup({
    type: 'ajax',
    callbacks: {
        ajaxContentAdded: function() {
            $('.fotorama').fotorama().destroy();
            $('.fotorama').fotorama();
        }
    }
});

N
Nadim Zakirov, 2020-07-15
@zkrvndm

Try to simply call the code in the forehead every second:

$(function() {
    setInterval(function() {
        $('.fotorama').fotorama();
    }, 1000);
})

If your photo frame is written correctly, it will skip the already initiated elements during repeated launches, which means that the method above is acceptable, although not ideal. Ideally, here you should use MutationObserver to track the fact of loading content, but I'm too lazy to write code with it)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question