2015-02-06 45 views
2

我正在使用Codeigniter框架和引導,進入這個安裝我有一些子頁面,其中一個我試圖有一個無限的滾動加載器。 爲此,我使用從本教程gridScrollFx.js下載的jQuery。 這是我的JS文件:如何在Codeigniter的可滾動部分創建一個無限的向下滾動網格加載器?

;(function(window) { 

'use strict'; 

var docElem = window.document.documentElement, 
    support = { animations : Modernizr.cssanimations }, 
    animEndEventNames = { 
     'WebkitAnimation' : 'webkitAnimationEnd', 
     'OAnimation' : 'oAnimationEnd', 
     'msAnimation' : 'MSAnimationEnd', 
     'animation' : 'animationend' 
    }, 
    // animation end event name 
    animEndEventName = animEndEventNames[ Modernizr.prefixed('animation') ]; 
... 
... 
// add to global namespace 
window.GridScrollFx = GridScrollFx; 
})(window); 

我從控制檯得到這個錯誤:「未定義是不是一個函數」此行:

animEndEventName = animEndEventNames[ Modernizr.prefixed('animation') 

在那裏我想有這種效果的網頁看起來像這樣:

<head>  
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/normalize.css" type="text/css" /> 
    <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/component.css" type="text/css" /> 
    <script src="<?php echo base_url(); ?>assets/js/modernizr.custom.js"></script> 
</head> 

<div class="container"> 
     <section class="grid-wrap">  
      <ul class="grid swipe-right" id="grid"> 

      <li><a href="#"><img src="<?php echo base_url(); ?>assets/css/themes/<?php echo $this->config->item("theme"); ?>/images/dummy.png" alt="dummy"><h3>A fantastic title</h3></a></li> 
... 
... 


      </ul> 
     </section> 

    <script src="<?php echo base_url(); ?>assets/js/imagesloaded.pkgd.min.js"></script> 
    <script src="<?php echo base_url(); ?>assets/js/colorfinder-1.1.js"></script> 
    <script src="<?php echo base_url(); ?>assets/js/masonry.pkgd.min.js"></script> 
    <script src="<?php echo base_url(); ?>assets/js/gridScrollFx.js"></script> 
    <script src="<?php echo base_url(); ?>assets/js/classie.js"></script> 

     <script> 
      new GridScrollFx(document.getElementById('grid'), { 
       viewportFactor : 0.4 
      }); 
     </script> 
</div> 

我該如何解決這個Javascript問題?

回答

0

來自PHP,所以也許讀這個錯誤。但我會嘗試:

function(window)

您沒有函數名稱,只有一個參數。窗口是函數的參數。試着按照教程找出名字應該是什麼?

+0

這是因爲Js文件結尾爲:\t'//添加到全局名稱空間 \t window.GridScrollFx = GridScrollFx; })(window);' – NineCattoRules 2015-02-06 14:39:45

1

您會收到此錯誤消息,因爲您的modernizr.custom.js不包含可選的Modernizr.prefixed()模塊。

您需要下載modernizr library並在「擴展性」部分選擇Modernizr.prefixed()模塊。

相關問題