jscroll jQuery和懒惰加载在一起无法工作

时间:2014-05-21 05:28:18

标签: javascript jquery

我的Web应用程序网格布局图像正在显示,但jscroll和延迟加载不能一起工作;只有jscroll插件正在运行。

请指导我如何实施。我是jQuery的初学者。如何修复多个jQuery冲突?

<script type="text/javascript">
    $(document).ready(function(){   
        $('.scroll').jscroll({  
            loadingHtml: '<img src="images/loader_lazy.gif" alt="Loading" /> Loading...',
            autoTriggerUntil: 3
        });
    });
</script>

1 个答案:

答案 0 :(得分:0)

=============== function.php ============================= ====

class modLazyloading extends constructClass {

    var $fileToLoad = '/engine/modules/lazyloading/test.php';
    var $iterations = 3;

    public function __construct($url='') {
        parent::__construct();
        if ($url!='') {$this->fileToLoad = $url;}
        if ($_GET['operation']==''){ $this->index(); }
        if ($_GET['operation']=='page'){ 
            $this->loadPage(); 
            $this->loadPageScript();
        }
    }

    public function index(){
        //$this->pageController->warstwaA();
        $this->view();
        //$this->pageController->warstwaB();
    }

    public function view(){
        echo "<div class='scroll'><a href='$this->fileToLoad?operation=page&id=$news_id&typ=$typ'>next page</a></div>
        <script type='text/javascript' src='/engine/lib/jscroll-master/jquery.jscroll.js'></script>
        <script>$('.scroll').jscroll({ autoTriggerUntil: $this->iterations });</script>";
    }

    public function loadPage(){
        echo 'loadpage P';
    }

    public function loadPageScript(){
        echo "<div class='scroll'><h3>Page 1</h3><p>Content here...</p><a href='$this->fileToLoad?operation=page'>next page</a></div>";
    }

}

==================== test.php ======================== =========

require_once 'modules/lazyloading/functions.php';

class lazyloading extends modLazyloading {

    public function loadPage() {
        echo 'testowa strona załadowana';
    }

    public function index(){
        $this->pageController->warstwaA();
        parent::index();
        $this->pageController->warstwaB();
    }

}

global $modLazyloading; $modLazyloading = new lazyloading();