1

对于 displayiny 画廊,我使用 lytebox。对于分页,我使用 AngularJS。虽然画廊的第一页工作正常,但下一页上的图片与 lytebox 无关。我认为原因是因为脚本 lytebox.js 在加载页面后仅在第一页上发现图片。如何在下一个画廊页面后强制 lytebox 刷新?

用于分页的 Html 和 AngularJS 脚本:

    <div class="row pictures">

    <div class="col-xs-3 picture td tac" ng-repeat="galeria in galerie">

        <?php if ($this->mySettings['lista_galerii']) : ?>
            <a href="<?php echo $this->baseUrl; ?>/Galeria/nr/{{ galeria.id}}">
                <img ng-src="<?php echo $this->baseUrl; ?>/public/admin/podstrony/{{ galeria.img}}" alt="{{ galeria.galnazwa}}" />
            </a>
            <a href="<?php echo $this->baseUrl; ?>/Galeria/nr/{{ galeria.id}}">
                <div class="nazwaGalerii">{{ galeria.galnazwa}}</div>
            </a>
        <?php else : ?>
            <a ng-show="!galeria.length" href="<?php echo $this->baseUrl; ?>/public/admin/podstrony/{{ galeria.img}}" 
               class="lytebox" data-lyte-options="group:galeria titleTop:false navTop:true" 
               data-title="<?php echo htmlspecialchars(stripslashes($html['link'])); ?>" 
               data-description="">
                <img class="galeriaImg" ng-src="<?php echo $this->baseUrl; ?>/public/admin/podstrony/{{ galeria.img}}" 
                     alt="<?php echo htmlspecialchars(stripslashes($html['link'])); ?>" 
                     title="<?php echo htmlspecialchars(stripslashes($html['link'])); ?>" />
            </a>
        <?php endif; ?>
    </div>
</div>
<div class="row">
    <div class="col-xs-12">
        <div class="dt center">
            <uib-pagination                             
                total-items="noArticles"
                max-size="10" 
                items-per-page="itemsPerPage"
                ng-model="currentPage" 
                ng-change="pageChanged()"                            
                previous-text="&lsaquo;" 
                next-text="&rsaquo;"                             
                >                            
            </uib-pagination>
        </div>
    </div>
</div>

<script type="text/javascript">
    app.controller('GaleriaController', ['$scope', '$filter', function ($scope, $filter) {
            //            $scope.galerie = <?= json_encode($this->galerie); ?>;
            $scope.zdjecia = <?= json_encode($this->galeria); ?>;

            $scope.itemsPerPage = 12;
            $scope.currentPage = 1;
            $scope.noArticles = $scope.zdjecia.length;

            $scope.todos = $scope.zdjecia;

            $scope.figureOutTodosToDisplay = function () {
                var begin = (($scope.currentPage - 1) * $scope.itemsPerPage);
                var end = begin + $scope.itemsPerPage;
                $scope.galerie = $scope.todos.slice(begin, end);
            };

            $scope.figureOutTodosToDisplay();

            $scope.pageChanged = function () {
                $scope.figureOutTodosToDisplay();
            };
            $scope.noArticles = $scope.zdjecia.length;

            $scope.pagesNo = $scope.noArticles / $scope.itemsPerPage;

            $scope.galerieGlownaMainpage = <?= json_encode($this->galerieStronaGlowna[0]); ?>;

        }]);
</script>
4

1 回答 1

0

我自己解决了这个问题。我初始化了lytebox $scope.pageChanged,它可以工作。

forceLyteboxInit = function () {
    setTimeout(
            function ()
            {
                initLytebox();
            }, 500);
}

$scope.figureOutTodosToDisplay();

$scope.pageChanged = function () {
    $scope.figureOutTodosToDisplay();
    forceLyteboxInit();
};
于 2016-10-12T07:19:28.893 回答