0

config フォルダーに pagination.php ファイルがあります。コードは以下です

$config['num_links'] = 5;
$config['use_page_numbers'] = TRUE;
$config['query_string_segment'] = 'page';

$config['full_tag_open'] = '<div class="pagination"><ul>';
$config['full_tag_close'] = '</ul></div>';

$config['first_link'] = '&laquo; First';
$config['first_tag_open'] = '<li class="prev page">';
$config['first_tag_close'] = '</li>';

$config['last_link'] = 'Last &raquo;';
$config['last_tag_open'] = '<li class="next page">';
$config['last_tag_close'] = '</li>';

$config['next_link'] = 'Next &rarr;';
$config['next_tag_open'] = '<li class="next page">';
$config['next_tag_close'] = '</li>';

$config['prev_link'] = '&larr; Previous';
$config['prev_tag_open'] = '<li class="prev page">';
$config['prev_tag_close'] = '</li>';

$config['cur_tag_open'] = '<li class="active"><a class="navigation" href="">';
$config['cur_tag_close'] = '</a></li>';

$config['num_tag_open'] = '<li class="page">';
$config['num_tag_close'] = '</li>';

codeigniterでjqueryプラグインの無限スクロールを使用するにはどうすればよいですか?

4

2 に答える 2

1

コードイグナイターでページネーションをスクロールするための簡単な手順があります。これを確認すると、よりうまく機能します

$(window).scroll(function(){
    if  ($(window).scrollTop() == $(document).height() - $(window).height()){
        // run our call for pagination
        var table = document.getElementById("table");
        var lastRowIndex = table.rows.length-1;
        loadMore(lastRowIndex);
    }
});

function loadMore(lastRowIndex)
{
$.ajax({
    url: "http://localhost/CodeIgniter/index.php/form/loadmore",  //form is y controller
    type:'POST',
    data: "row="+lastRowIndex, // row wich is post
    success: function(data){    //here data which recevie form controller
        var json = JSON.parse(data);
        var count = json.length;
        var html;
        for( var i = 0; i < count; i++ )
        {
            html += '<tr>';
            html += '<td><input type="checkbox" name="id[]" id="id[]" class="check" value="'+ json[i].id +' "></td>';
            html += '<td>'+ json[i].id +'</td>';
            html += '<td><img src="http://localhost/CodeIgniter/upload/'+ json[i].image +'" class="img-circle" height="25" width="30"></td>';
            html += '<td> ' + json[i].firstname +'</td>';
            html += '<td> ' + json[i].middlename +'</td>';
            html += '<td> ' + json[i].lastname +'</td>';
            html += '<td> ' + json[i].address +'</td>';
            html += '<td> ' + json[i].mobile +'</td>';
            html += '<td> ' + json[i].email +'</td>';
            html += '<td> ' + json[i].gender +'</td>';
            html += '<td><a href="http://localhost/CodeIgniter/index.php/form/del/'+ json[i].id +'">Delete</a></td>';
            html += '<td><a href="http://localhost/CodeIgniter/index.php/form/edite/'+ json[i].id +'">Update</a></td>';
            html += '</tr>';
        }$("#body").append(html); //add this html to th table body which id='body'
    }   
});
}

私はこのコントローラ機能を使用します

 public function loadmore()
 {
    $page=$_POST['row'];
    $per_page = 10;
    $student = $this->Form_model->getview_detail($per_page,$page);
    if($student !== FALSE)
    {
        echo json_encode($student); //send data to script
    }
}

そしてこれがモデル

public function getview_detail($limit, $start)
{
    $this->db->limit($limit, $start);
    $query = $this->db->get('form');
    return $query->result_array();
}    
于 2016-10-03T12:13:28.790 に答える