javascript - owl carousel doesn't work properly on ajax loaded items -


i using owl-carousel working pretty when load items directly. although, when try load items through ajax, been rendered not been displayed , not navigation works.

jquery initialize carousel

    $(".pos-carousel").owlcarousel({     center: true,     items: 1,     loop: true,     margin: 15,     nav: true,     responsive: {         640: {             items: 2,             autowidth: true,             margin: 30         }     } }); 

html....

<div id="creationselectitem"> <div class="module-content carousel owl-carousel owl-theme pos-carousel creationselectitem-carousel"> </div> 

jquery loads items

    $(".brand-selection-item img").click(function () {     var selectedbrand = $(this).attr('data-selected-brand');      $.get("/umbraco/surface/poscreate/gettypestyleoptions", { brandname: selectedbrand }, function (data) {         $(".creationselectitem-carousel").html(data);     }); }); 

i log on console: error log welcome!

you need initialize carousel after loading data :

$.get("/umbraco/surface/poscreate/gettypestyleoptions", { brandname: selectedbrand }, function (data) {      $(".creationselectitem-carousel").html(data);      $(".pos-carousel").owlcarousel({         center: true,         items: 1,         loop: true,         margin: 15,         nav: true,         responsive: {            640: {               items: 2,               autowidth: true,               margin: 30            }        }     }); }); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -