After reading the CI paging class, I did not write about AJAX. I also saw several other paging class extensions on the forum, which I think is not necessary.
On the basis of the existing, a small change can still be implemented.
Enter the subject below:
The native paging class of CI has a parameter $ config [anchor_class]
This parameter is used to set the pagination link style, so we can set it as follows:
$ Config [anchor_class] = "class = ajax_fpage ";
In the view section, disable the default action of the signature to obtain the AJAX effect.
The Code is as follows:
Copy codeThe Code is as follows: <script>
$ (. Ajax_fpage). click (function (e ){
Var url = $ (this). attr (href );
$. Get (url, {}, function (res ){
Certificate (+show_what_table).html (res );
});
Event. preventDefault ();
});
</Script>
When you click ajax_fpage, disable the default action of the tag and obtain the href information. Then, use the get method to obtain the href content and update the dom.
This completes ajax paging. Therefore, you do not need to extend the original class.
The detailed PHP code is as follows:
Copy codeThe Code is 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 );
}