2014-09-22 84 views
0

你好,我剛剛開始web開發。我正在使用Yii 1.1的JS函數掙扎:isotope-jquery。試圖展示無限滾動的砌體圖庫。如果我保留原樣,但是在使用圖像時,它們會在最後重疊。我應該使用imagesLoaded,但應用it's正在痛苦......砌體+同位素+ imagesLoaded沒有定義yii

原始代碼:

$defaultCallback=" 
     function(newElements) { 
     /* hide new items while they are loading*/ 
     var newElems = jQuery(newElements); 
     \$isoContainer.isotope('appended', newElems, true); 
     {$this->infiniteCallback} 
     }"; 

修改:

["math:", 222, 2853] jquery.infinitescroll.js:171 
["math:", 0, 2853] jquery.infinitescroll.js:171 
["heading into ajax", Array[2]] jquery.infinitescroll.js:171 
["Using HTML via .load() method"] jquery.infinitescroll.js:171 
["contentSelector", div.items.isotope] jquery.infinitescroll.js:171 
Uncaught ReferenceError: $newElems is not defined index.php?r=products:112(anonymous function) index.php?r=products:112opts.callback jquery.infinitescroll.js:159infscr_loadcallback jquery.infinitescroll.js:327infscr_ajax_callback jquery.infinitescroll.js:501jQuery.extend.each jquery.js:595jQuery.fn.jQuery.each jquery.js:241jQuery.ajax.complete jquery.js:7465fire jquery.js:974self.fireWith jquery.js:1084done jquery.js:7818callback 

function(newElements) { 
     /* hide new items while they are loading*/ 
     var newElems = jQuery(newElements); 
     \$newElems.imagesLoaded(function(){   
      \$isoContainer.masonry('insert', newElems); 
     }); 
     {$this->infiniteCallback} 
     }" 

瀏覽器控制檯上的錯誤

我已經嘗試了幾個東西,定義裏面的var,傳遞參數,但是我不能讓它工作...

可能it's一個新手的問​​題...

感謝您的幫助

+0

使用同位素或磚石?您的更新代碼已砌築 – Macsupport 2014-09-22 22:31:12

+0

我正在使用(嘗試)砌體佈局模式,謝謝 – user4055746 2014-09-23 12:41:54

+0

您尚未提供足夠的信息來解決您的問題。你需要發佈更多的代碼。更好的是,做一個jsfiddle。另外,你使用砌體,但你似乎正在加載同位素(?)'[「contentSelector」,div.items.isotope]' – Macsupport 2014-09-23 13:29:39

回答

1

所以這是解決方案,以及工程就像一個魅力!

function(newElements) { 
     /* hide new items while they are loading*/ 
     var newElems = jQuery(newElements); 
     \$isoContainer.imagesLoaded(function(){   
     \$isoContainer.isotope('appended', newElems,true); 
     }); 

感謝@Macsupport