我正在尝试在我的yii2项目中实现一个滑块,我上周开始使用yii我不知道我是否做了正确的事情,我下载了this代码,但我使用它的方式不是100%工作,图像和缩略图显示,但我不能点击缩略图来更改背景,原始代码工作正常,问题是我不能让它在我的yii项目中工作
<?php
$dataProvider = new ActiveDataProvider([
'query' => Cake::find(),
]);
?>
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemView' => '_bolos',
'summary' => '',
'options' => [
'tag' => 'div',
'id' => 'gallery',
'class' => 'bigImages',
],
]); ?>_bolos:
<?php
use yii\helpers\Html;
/* @var $model \app\models\Cake */
?>
<script>
<?php $this->beginBlock('page-script') ?>
(function () {
$("#gallery").fullscreenGallery();
})();
<?php $this->endBlock() ?>
</script>
<?php $this->registerJs($this->blocks['page-script']) ?>
<div id="gallery">
<div class="bigImages">
<ul>
<li> <?= Html::img($model->cakePhotos[0]->getUploadUrl('file'), ['width' => '100%']); ?></li>
</ul>
</div>
<div class="thumbnails">
<ul>
<li> <?= Html::img($model->cakePhotos[0]->getThumbUploadUrl('file')); ?></li>
</ul>
</div>
</div>发布于 2016-09-28 23:44:24
小部件ListView将为将从$dataProvider检索到的每个Cake模型呈现_bolos.php视图。因此,您的页面将包含很少的#gallery div元素和js脚本(请参阅您的页面源代码)。因此它不能被正确初始化。
需要将所有不应重复的图元移动到主视图中。
https://stackoverflow.com/questions/39711825
复制相似问题