2013-10-30 39 views
5

我正面臨着一個令人討厭的問題,將Wordpress中的無限滾動插件與使用砌體的主題集成在一起。無限滾動砌體在woocommerce不起作用

我有最新版本的無限滾動,2.6.2的,我已經在插件的回調部分添加以下代碼:

// hide new items while they are loading 
var $newElems = jQuery(newElements).css({ opacity: 0 }); 
// ensure that images load before adding to masonry layout 
$newElems.imagesLoaded(function(){ 
// show elems now they're ready 
$newElems.animate({ opacity: 1 }); 
    $container.masonry('appended', $newElems, true); 
}); 

,但它不工作,它增加不透明度爲新元素,但它並沒有增加職位等,所以不太工作;新項目將在舊版產品的頁面頂部進行。

腳本的樣子:

/* <![CDATA[/
var infinite_scroll = "{\"loading\":{\"msgText\":\"Loading...<\\/em>\",\"finishedMsg\":\"No additional products.<\\/em>\",\"img\":\"http:\\/\\/www.test.com\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".next\",\"navSelector\":\".woo-pagination\",\"itemSelector\":\"li.product\",\"contentSelector\":\"ul.products\",\"debug\":false,\"behavior\":\"\",\"callback\":\"\\\/\\\/ hide new items while they are loading\r\nvar $newElems = jQuery(newElements).css({ opacity: 0 });\r\n\\/\\/ ensure that images load before adding to masonry layout\r\n$newElems.imagesLoaded(function(){\r\n\\/\\/ show elems now they're ready\r\n$newElems.animate({ opacity: 1 });\r\n$container.masonry('appended', $newElems, true);\r\n});\"}"; 
/]]> */ 

砌築的樣子:

// Only fire masonry if the window is an appropriate size and images are loaded 
jQuery(function(){ 
    var $container = jQuery('ul.products'); 
    $container.imagesLoaded(function(){ 
     if (jQuery(window).width() > 767) { 
      $container.masonry({ 
       itemSelector : 'li.product', 
       columnWidth : 295, 
       isFitWidth: true, 
       gutterWidth : 2 
      }); 
     } 
    }); 
}); 

回答

3

無限滾動的WordPress的插件:Here's the link,有一個名爲behavior一個選項,在這裏你可以選擇砌體 ,當然你需要選擇正確的選擇器,之後就會像魅力一樣工作,看到更多的開發選項,你可以訪問the developers website