Looked at the CI page class did not write about Ajax content, but also saw several other great God wrote the page class extension, it is not really necessary.
Making a small change on the existing basis is still achievable.
Let's get down to business:
CI's original Zoning page class has a parameter $config [Anchor_class]
This parameter is used to set the style of the pagination link, so we can set it like this:
$config [Anchor_class] = "Class=ajax_fpage";
Then, in the View section, we use the method of prohibiting the default action of a pad to obtain the effect of Ajax.
The code is as follows:
Copy Code code as follows:
<script>
$ (. ajax_fpage). Click (function (e) {
var url = $ (this). attr (HREF);
$.get (Url,{},function (res) {
$ (#show_what_table). HTML (res);
});
Event.preventdefault ();
});
</script>
When ajax_fpage clicks, the default action of a label is banned, the href information is obtained, and the Get method is used to get the content of the HREF and update the DOM.
Such a complete Ajax paging is achieved. This does not require an extension of the original class.
detailed PHP code is as follows:
Copy Code code as follows:
function ContentList ($id, $p =0)
{
$this->load->library (pagination);
$config [Base_url] = Site_url (qyadmin/contentlist/. $id./. $p);
$config [Total_rows] = $this->admin->content_list ($id, $p, 1);
$config [Per_page] = 5;
$config [Uri_segment] = 5;
$config [First_link] = FALSE;
$config [Last_link] = FALSE;
$config [Full_tag_open] = <p>;
$config [Full_tag_close] = </p>;
$config [Display_pages] = FALSE;
$this->load->helper (URL);
$skin _url = Base_url (). AppPath. "Views/templates";
$config [Next_link] = ;
$config [Next_tag_open] = <li class= "FR" >;
$config [Next_tag_close] = </li>;
$config [Prev_link] = ;
$config [Prev_tag_open] = <li class= "FR" >;
$config [Prev_tag_close] = </li>;
$config [Anchor_class] = class= "Ajax_fpage";
$this->pagination->initialize ($config);
$content = $this->admin->content_list ($id, $p, 0, $config [per_page], $this->uri->segment (5));
$fpage = $this->pagination->create_links ();
$this->smarty->assign (Fpage, $fpage);
$this->smarty->assign (content, $content);
$this->smarty->view (SHOW.TPL);
}