2012-07-17 107 views
1

這裏是我的代碼:jQuery的砌體和無限滾動

var $container = jQuery('#hentry-wrapper'); 
    $container.imagesLoaded(function(){ 
     $container.masonry({ 
      itemSelector : '.hentry', 
      columnWidth: 454, 
      gutterWidth: 30, 
      isResizable: true 
     }); 
    }); 

    $container.infinitescroll({ 
     navSelector : '#nav-pagination', 
     nextSelector : '#nav-pagination .next', 
     itemSelector : '.hentry', 
     loading: { 
      finishedMsg: 'No more pages to load.', 
      img: 'http://i.imgur.com/6RMhx.gif' 
     } 
    }, 
    // trigger Masonry as a callback 
    function(newElements) { 
     // 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); 
     }); 
    }); 

    // kill scroll binding 
    jQuery(window).unbind('.infscr'); 

    // hook up the manual click guy. 
    jQuery('#load-more').click(function(){ 
     $container.infinitescroll('retrieve'); 
     return false; 
    }); 

    // remove the paginator when we're done. 
    jQuery(document).ajaxError(function(e,xhr,opt){ 
     if (xhr.status == 404) jQuery('#load-more').remove(); 
    }); 

的問題是,#負載更沒有當我們做了刪除。但這裏很好http://www.infinite-scroll.com/trigger.html有什麼問題?請幫忙嗎?

回答

1

最後一頁不應該包含#load-more元素。

+0

我知道,我需要將其刪除。 – 2012-07-17 12:30:36

+0

當你生成html頁面時,你知道你是否在最後,如果是這樣,你不會在你的頁面添加html元素「#load-more」。 – tekilatexee 2012-07-17 12:56:01