我正在尝试使用Infinite scroll jquery plugin为 codeigniter 的分页添加无限滚动。但没有成功
这是我的控制器:
$config['base_url'] = site_url('news/home/');
$config['total_rows'] = $this->home_model->count_new();
$config['per_page'] = 3;
$config['uri_segment'] = 3;
$config['limit'] = $config['per_page'];
$this->pagination->initialize($config);
$data['news'] = $this->home_model->list_data_new($config['per_page'], $this->uri->segment($config['uri_segment']));
$this->load->view('news_view',$data);
这是我的观点:
<div id="content">
<?php foreach ($news as $data):?>
<?php echo $data['title']?>
Post by: <?php echo $data['username']?>
<?php endforeach;?>
</div>
<button id="next">load more</button>
这里也是 javascript 的视图:
$('#content').infinitescroll({
navSelector : "#next:last",
// selector for the paged navigation (it will be hidden)
nextSelector : "#next:last",
// selector for the NEXT link (to page 2)
itemSelector : "#content"
// selector for all items you'll retrieve
});
分页链接会是这个样子http://localhost/latihan/news/home/3
然后点击下一步就会是这个样子http://localhost/latihan/news/home/6
问题是下一篇文章没有显示并且加载更多按钮没有加载数据。
有什么答案吗?
非常感谢...