2012-10-23 49 views
4

我試着去實現此處(https://github.com/jney/jquery.pageless)發現了無盡的分頁jQuery插件到我笨項目。笨/ jQuery的 - 分頁 - 無盡分頁

jQuery代碼我輸入相同什麼演示頁

$('#results').pageless({ totalPages: 10 
, url: '/theurl/index' 
, loaderMsg: 'Loading more results' 
}); 

和代碼,我在我的笨控制器如下

$config['base_url'] = base_url() . 'theurl/index'; 
    $config['total_rows'] = $this->model->record_count(); 
    $config['per_page'] = 20; 
    $config['uri_segment'] = 3; 

    // Init the config 
    $this->pagination->initialize($config); 

    // Create pagination 
    $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; 
    $data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page); 
    $data['links'] = $this->pagination->create_links(); 

    // Load the view and pass through all the data 
    $this->load->view('theurl/index', $data); 

當我運行的代碼上,併到達頁面的底部,它可以工作,但它也會將輸入頁面加載到它爲結果創建的新div中。

任何幫助將不勝感激。

乾杯

+0

你的意思是「整個頁面吧?那麼,如果是「整個」頁面,那麼您正在加載的視圖究竟是什麼,這是您將嵌套在成功的分頁調用上的內容。 –

+0

喂大衛,感謝您的答覆......這非常有意義......會是什麼來解決這個問題的最好方法是什麼? – BigJobbies

+0

創建一個視圖,其中只包含需要在分頁結果中顯示的數據,然後調用該數據。 –

回答

2

也許你應該的結果加載到一個局部視圖,因爲否則你再次加載整個頁面。創建一個局部視圖來加載所有數據,然後,局部視圖加載到主頁面:

$config['base_url'] = base_url() . 'theurl/index'; 
$config['total_rows'] = $this->model->record_count(); 
$config['per_page'] = 20; 
$config['uri_segment'] = 3; 

// Init the config 
$this->pagination->initialize($config); 

// Create pagination 
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0; 
$data['results'] = $this->onyafeet->fetch_results($config['per_page'], $page); 
$data['links'] = $this->pagination->create_links(); 
// AJAX load: 
if ($this->input->is_ajax_request) { 
    $this->load->view('theurl/partial/ajax_partial',$data); 
} 
else { 
    // Load the view and pass through all the data 
    $this->load->view('theurl/index', $data); 
} 

我認爲這種方法應該工作,局部視圖只能有你想要的右邊部分顯示,div與你想異步加載的所有內容。

+0

感謝您的..它那種工作,只是現在它加載同樣的結果,也是它不會,除非我遍歷工作結果無論在局部和非局部視圖:S – BigJobbies

+0

嗯...望着「pageless」的設置,我認爲你的問題可能是關於你的看法標記:主視圖(「theurl /指數」)應該有一個標記元素,您將在其中收取下一個項目。在「pageless」我已經看到了你可以指定這個標記元素,也許設置:$(「#結果」)pageless({總頁數:10 ,網址:「/ theurl /指數」 ,loaderMsg:「加載更多結果',container:'#element'});並在MAIN頁面中添加

BLABLA
即可使用。 – Chococroc