首页 > 解决方案 > 在动态图像加载时刷新 owl-carousel2

问题描述

我需要<td>根据 PHP 提供的图像数组在 dataTable 中动态显示图像轮播。现在我得到的只是一堆所有图像。
在线搜索我发现我必须在加载所有图像后重新加载轮播td,但我不知道如何。

这是我的html:

<?php foreach ($intest as $int) {
            if (is_array($int['cartella'])) {
                foreach ($int['cartella'] as $cartella){ ?>
                    <td><div class="owl-carousel owl-theme prova" >
                   <?php $files =  "images/" . Yii::app()->session['dominio']."/".$row['num_registraz']."/". $cartella."/";
                    //CVarDumper::dump($file);
                    if(is_dir($files)){ 
                        if ($dh = opendir($files)) {
                            while (false !== ($file = readdir($dh))) {
                                if($file == '.' || $file == '..'){
                                    continue;
                                }
                                $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
                                if ($ext=='jpg' || $ext=='jpeg' || $ext=='png' || $ext=='gif'){?> 
                                <img class="mia" src="<?= $files.$file ?>">
                                <?php } else if ($ext == 'pdf'){ ?>
                                <div>File PDF</div>
                                <?php }  else if ($ext == 'doc' || $ext =='docx') {?>
                                <div>File DOC</div>
                                <?php } else {?>
                                <div>Unsupported file</div>
                                <?php } } } }else if (!is_dir($files)){ ?>
                                    No foto
        <?php } } } } } ?>
                    </div></td>

这是我尝试重新加载的Javascript

var car = $('#prova');
        car.on('load', function(){
            car.trigger('destroy.owl.carousel');
            car.owlCarousel({
               'items':1
            });
        });

任何帮助将不胜感激

标签: javascriptphpyiiowl-carousel

解决方案


推荐阅读