Owl Carousel not showing in Elementor live preview Owl Carousel not showing in Elementor live preview wordpress wordpress

Owl Carousel not showing in Elementor live preview


As @nukeurself said, the owl function called at the wrong time. As he mentioned appending the following line to render() function makes the owl function called at the right time.

if (is_admin()){   echo "<script>$('.owl-carousel').owlCarousel();</script>";}

But this doesn't solve the width problem. In order to solve both owl function issue and the width issue, the following code lines have to be appended with the render() function. The following lines make the owl function load after the elementor scripts are fully loaded.

...protected function render(){  ...  if (is_admin())  {    // solves the width issue    // The javascript called after elementor scripts are fully loaded.    if ( ! defined( 'ELEMENTOR_VERSION' ) ) {        return;    }    echo "<script>$('.owl-carousel').owlCarousel();</script>";  }}


i know its a bit late, but i had the same problem.

The problem is, that the owl function gets called at the wrong time. (I assume at page load).

Just call owl carousel at the end of your render function and it should work.

Like so:

...protected function render(){  ...  if (is_admin())  {    echo "<script>$('.owl-carousel').owlCarousel();</script>";  }}


     if ( Plugin::$instance->editor->is_edit_mode() ) : ?>    <script>        $('.owl-screenshot').owlCarousel({        loop:true,        autoplay:true,        margin:10,        nav:false,        dots:true,        navText : ["<i class='fa fa-angle-left'></i>","<i class='fa fa-angle-right'></i>"],        responsive:{            0:{                items:2            },            600:{                items:3            },            1000:{                items:4            }        }    })    </script>        <?php endif;