M
M
Mikhail Belyakov2018-02-13 13:31:12
JavaScript
Mikhail Belyakov, 2018-02-13 13:31:12

How to parse ajax in callback(e)?

There is an execution script that executes the following image carousel, when clicked, the magnific popup script fires, which creates a tpl page with another carousel, which should be parsed in callback, but nothing comes out of you, even the console log callback does not work.

<script>
    $(document).ready(function () {
        $('.owl-carousel').owlCarousel({
            loop: false,
            margin: 10,
            nav: true,
            responsive: {
                0: {
                    items: 1
                },
                600: {
                    items: 3
                },
                1000: {
                    items: 5
                }
            }
        });

        $('.open-popup-link').on('click', function () {

            var post_id = $(this).attr('data-post_id');

            $.magnificPopup.open({
                type: 'ajax',
                items: {
                    src: 'index.php?route=instagram/instagram/getMedia&post_id=' + post_id,
                },
                callbacks:
                    {
                        parseAjax: function () {
                            console.log("callback called! "),
                                $('.owl-carouseles').owlCarousel({
                                    loop: false,
                                    margin: 100,
                                    nav: true,
                                    responsive: {
                                        0: {
                                            items: 1
                                        },
                                        600: {
                                            items: 3
                                        },
                                        1000: {
                                            items: 5
                                        }
                                    }
                                })

                        }
                    }

            });


        });

    });


</script>


The page that is created when opening a photo in the initial carousel
<div class="owl-carouseles">
    <?php foreach ($posts as $post) { ?>
    <div class="item">
    <?php if (isset ($post['image'])) { ?>
         <img src="<?= $post['image']; ?>">
    <?php } ?>
    <?php if (!empty($post['video'])) { ?>
        <video src="<?= $post['video']; ?>" height="640" autoplay loop></video>
    </div>
    <?php } ?>
    </div>
    <?php } ?>
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question