In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to achieve AJAX paging in CI. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.
Topic:
CI's native paging class has a parameter $config[anchor_class]
This parameter is used to set the style of pagination links, so we can set it like this:
$config[anchor_class] = "class=ajax_fpage";
Then in the view section, this method of prohibiting the default action of a note is used to obtain the AJAX call effect.
The code is as follows:
$(.ajax_fpage).click(function(e){
var url = $(this).attr(href);
$.get(url,{},function(res){
$(#show_what_table).html(res);
});
event.preventDefault();
});
When ajax_fpage is clicked, disable the default action of a tag, and get href information, then use the get method to get the content of href, and update dom.
A complete Ajax page is created. So there is no need to extend the original class.
The detailed PHP 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);
}
About "CI how to achieve AJAX paging" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.