2012-10-15 66 views
-3

無限滾動應在10行記錄後停止。如果有更多的記錄,應顯示ajax分頁。例如,考慮this infinite scrolling example
所以在20條記錄後,我想要顯示分頁,並且應該在下一頁上完成。請讓我知道,如果你有任何這樣的想法或解決方案。使用ajax分頁的無限滾動(經過一些滾動顯示分頁)

這裏是我的代碼上我的工作:

//On doMouseWheel = 1 I have taken the currentdealoffset value and check it with the total no of deals present 
    //If count is less, then simply calculating the window position displaying the allotted records say 10 
    //On next scroll just doing the same process and fetching records using ajax until end of the deals 
    //Now the problem is I am not able to code a logic where after say 10 records show a pagination and 
    //When click on next page the same process should be managed by fetching the offset count of scrol and offset of pagination bar 

    doMouseWheel = 1 ; 

      $(window).scroll(function() { 
      if($('#facebox_overlay').is(':visible')==false){     
      $('#endofdeals').show(); 
      $('#endofdeals').html("<center><img src='"+SITEIMG +"ajax-loader_1.gif' ><center>"); 
      //console.log("Window Scroll ----"); 
      var currentdealoffset = 0; //alert(currentdealoffset); 
      var currentdealoffset = parseInt(document.getElementById("countval").value); //alert(currentdealoffset); 
      var displaymode = parseInt($('#displaymode').val()); 
      var totalcountdeal = parseInt($('#totaldeals').val()); //alert(totalcountdeal); 
      if(currentdealoffset<totalcountdeal){ 
      if (!doMouseWheel) { 
      return ; 
      } ; 

      var distanceTop = $('#last').offset().top - $(window).height();   
        if ($(window).scrollTop() > distanceTop){ 
      //console.log("Window distanceTop to scrollTop Start"); 
      doMouseWheel = 0 ; 
        $('div#loadMoreComments').show(5000); 
        //console.log("Another window to the end !!!! "+$(".postedComment:last").attr('id'));   

        $.ajax({ 
        type : 'POST', 
        dataType : "html", 
        data: { 
        typeday : $('#remdumtype').val(),       
        catid : $('#catid').val(),       
        }, 
        url: "<?php echo https_url($this->config->item('base_url'))?>popup/dealsearch", 
        success: function(html) { 
        doMouseWheel = 1; 
        if(html){ 
        if(displaymode==12) 
        $('#listTable tr:last').after(html); 
        else 
        $("#postedComments").append(html); 
        //console.log("Append html--------- " +$(".postedComment:first").attr('id')); 
        //console.log("Append html--------- " +$(".postedComment:last").attr('id')); 
        $("#last").remove(); 
        $("#postedComments").append("<p id='last'></p>"); 
        $('div#loadMoreComments').hide(); 
        $('#endofdeals').hide(); 
        } 
        } 
        }); 
        } 
      } 
      else 
        { 
          if($('#endofdeals')!='') 
          { 
          $('#endofdeals').hide(); 
          if(currentdealoffset < displaymode) 
            { 
              $('#endofdeals').hide(); 
            }else if(currentdealoffset > displaymode) 
            { 
              $('#endofdeals').show(); 
              $('#endofdeals').html("<center><h2 style='color:#4C335B'>End of deals !!!!!!!</h2></center>"); 
            } 
          } 
        } 
        } 
        }); 
+2

你應該爲谷歌一個無限的滾動庫它應該有一個回調函數加載數據執行Ajax請求。鉤功能! – MaX

+2

請告訴我們你到目前爲止所嘗試過的,所以我們可以給你建議。沒有人會解決你的問題,如果你不表明你已經努力 – Sheena

+0

@sheena:請檢查我的更新 –

回答

1

據我,你想頁碼但是當你滾動頁面應該加載緩慢。 如果你想的話,你不應該使用無限滾動的技術,但LazyScroll會幫助你,如果你想20條記錄,然後讓你查詢20個記錄也創造pagination下面

在這裏,你可以有Plug-inDemo