javascript - 在动态图像加载时刷新 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
});
});
任何帮助将不胜感激
解决方案
推荐阅读
- html - 带有背景图像的 div 被另一个带有背景图像的 div 覆盖
- python - Python Pulp 绝对约束
- testing - TFS 自动重置测试结果
- mysql - MySQL - 获取具有相同标识符的上一行
- c# - 如何修改位于datagridView中的复选框
- angular - 如何在角度 6 中为 mat-card 设置默认侧栏
- apache - 子域在 Apache2/Debian9 上不起作用
- reactjs - 如何将 SPFx 和 Reactjs 更改为 SPFx React-Redux?
- java - 如何在单独的行中打印每个地图条目的地图列表
- angular - ngFor 添加数组长度 - Angular 6