S
S
Slava_Fame2019-07-26 13:35:46
JavaScript
Slava_Fame, 2019-07-26 13:35:46

How to open the desired slide in owl-carousel2 on click?

Good afternoon. When clicking on a link, I need to open a certain slide in a modal window (on materialize-css). I'm trying to do it like here: https://owlcarousel2.github.io/OwlCarousel2/demos/... but the first slide still opens. Here is the code:

<!-- OWL-Carousel -->
        var owl_doctor = $("#doctors_slider");
        owl_doctor.owlCarousel({
          loop: true,
          nav: false,
          URLhashListener:true,
          autoplayHoverPause:true,
          startPosition: 'URLHash'
          }
        });

    <!-- мой слайдер -->
<div id="modal3" class="modal doctor">
<div class="modal-content">
    <div id="doctors_slider" class="owl-carousel owl-theme doctor_slider">
            <?php 
                $args = array(
                    'post_type' => 'Specialists',
                    'post_per_page' => -1,
                    'order' => 'asc',
                        );
                $specialists = new WP_Query( $args ); 

                $counter = 0;

                if( $specialists->have_posts() ) {
                    while ($specialists->have_posts() ) {
                    $specialists->the_post(); $counter++ ?>
                <!-- слайды -->
                <div class="doctors_slider__item" data-hash="slide-<?php echo $counter; ?>" id="slide-<?php echo $counter; ?>"></div>
</div>
</div>
</div>
    <!-- ссылка по которой открывается слайд в модальном окне -->
    <a class="modal-trigger certificate_trigger" data-target="modal3" href="#slide-<?php echo $counter; ?>">Подробнее</a>

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