title: Infinite scrolling with ajax paging (After some scroll show pagination)
body: <p>Infinite scroll should stop after 10 rows of records. If there are more records, ajax pagination should be displayed. For example, consider <a href="http://www.jquery4u.com/demos/infinite-scrolling-demo5/" rel="nofollow">this infinite scrolling example</a>.<br>
  So after 20 records I want to display pagination and same should be done on next page. Please let me know if you have any of this ideas or solution.</p>
  
  <p>Here is my code on which I am working:</p>
  
  <pre><code>    //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("&lt;center&gt;&lt;img src='"+SITEIMG +"ajax-loader_1.gif' &gt;&lt;center&gt;");
              //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&lt;totalcountdeal){
              if (!doMouseWheel)  {
              return ;
              } ;
  
              var distanceTop = $('#last').offset().top - $(window).height();        
                      if  ($(window).scrollTop() &gt; 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: "&lt;?php echo https_url($this-&gt;config-&gt;item('base_url'))?&gt;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( "&lt;p id='last'&gt;&lt;/p&gt;" );
                      $('div#loadMoreComments').hide();
                      $('#endofdeals').hide();
                      }
                      }
                      });
                      }
              }
              else
                      {
                              if($('#endofdeals')!='')
                              {
                              $('#endofdeals').hide(); 
                              if(currentdealoffset &lt; displaymode)
                                      {
                                              $('#endofdeals').hide();
                                      }else if(currentdealoffset &gt; displaymode)
                                      {
                                              $('#endofdeals').show();
                                              $('#endofdeals').html("&lt;center&gt;&lt;h2 style='color:#4C335B'&gt;End of deals !!!!!!!&lt;/h2&gt;&lt;/center&gt;");
                                      }
                              }
                      }
                      }
                      });
  </code></pre>