A _php tutorial on the Ajax pagination alternative implementation method for CI analysis

Source: Internet
Author: User
Read the CI of the pagination class did not write about the content of Ajax, but also on the forum to see the other large gods written by the extension of the paging class, the feeling is actually not necessary.
It is possible to make a small change on the basis of the existing one.
below to get to the chase:
CI has a parameter in the original zoning page class $config [Anchor_class]
This parameter is used to set the style of the paging link, so we can set it up like this:
$config [Anchor_class] = "Class=ajax_fpage";
Then, in the View section, the method of prohibiting a sticky note default action is used to get the effect of Ajax.
The code is as follows:
Copy CodeThe code is as follows:


When ajax_fpage clicks, the default action of the A tag is forbidden, and the href information is obtained, then the contents of the href are obtained using the Get method, and the DOM is updated.

Such a complete AJAX paging is implemented. 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] =

;
$config [Full_tag_close] =

;
$config [Display_pages] = FALSE;
$this->load->helper (URL);
$skin _url = Base_url (). APPPATH. "Views/templates";
$config [Next_link] =;
$config [Next_tag_open] =
  • ;
    $config [Next_tag_close] =
  • ;
    $config [Prev_link] =;
    $config [Prev_tag_open] =
  • ;
    $config [Prev_tag_close] =
  • ;
    $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);
    }

    http://www.bkjia.com/PHPjc/327887.html www.bkjia.com true http://www.bkjia.com/PHPjc/327887.html techarticle read the CI of the pagination class did not write about the content of Ajax, but also on the forum to see the other large gods written by the extension of the paging class, the feeling is actually not necessary. On the basis of the existing to do a ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.