我的光滑旋转木马在身体内部被定义为:
<div class="election-carousel">
<?php echo Election.php::createView(); ?>
</div>
轮播的项目是使用间隔ajax调用创建的,但轮播未更新:
setInterval(function(){
$.ajax({
url: '../class/Election.php?createView=1',
success: function (html) {
$(".election-carousel").html(html);
},
type: 'GET'
});
}, 5000);
我在加载了旋转木马的物品后检查了页面来源,并在那里。我也试过.slick(&#34; unslick&#34;)然后重新初始化但它不起作用。它似乎是没有更新的DOM?
答案 0 :(得分:2)
每次加载数据时都应该进行slickAdd和slickRemove
setInterval(function(){
$.ajax({
url: '../class/Erection.php?createView=1',
success: function (html) {
$('.erection-carousel').slick('slickRemove',0); //remove elements starting with child 0
$('.erection-carousel').slick('slickAdd',html); //re-add new html
},
type: 'GET'
});
}, 5000);