在CI阿贾克斯jQuery的分页错误 [英] Error in ajax jquery pagination in CI
问题描述
在codeigniter jQuery的分页遇到错误。
如果per_page = 5;
总数6和总第2页
但是像下面的分页
显示6 6 6 | < 1 2
但只有5所示,并在第二页最后一个节目。
喜的朋友,我陷在这个bug.This显示在每一个pages.Pls给我一个解决方案,以获得正确的分页
低于code使用:
$配置['BASE_URL'] = SITE_URL(设置/ view_leave_reason_ajax /');
$配置['total_rows'] = $这个 - > leav-> getLvReasonCount();
$配置['per_page'] = 5;
$配置['anchor_class'] ='ajax_links';
$配置['show_count'] =真;
$配置['格'] ='#list_view';
$这个 - > jquery_pagination->初始化($配置);
$页=($这 - > URI的>段(3))? $这 - > URI的>链段(3):0;
$数据[链接] = $这个 - > jquery_pagination-> create_links();
$数据['页'] = $页;
$数据['结果'] = $这个 - > leav-> getLvReason($配置[per_page],$页);
对于低于CI分页问题:
<一个href="https://github.com/neotohin/$c$cIgniter-Ajax-pagination-Library">https://github.com/neotohin/$c$cIgniter-Ajax-pagination-Library
查看页面:
&LT;如果PHP($结果==)
{&GT?;
&LT; TR风格=高度:50像素;背景:#FFFFFF;字体重量:大胆;&GT;
&LT; TD合并单元格=5的风格=宽度:50像素;&GT;
无详细信息的存在
&LT; / TD&GT;
&LT; / TR&GT;
&LT; PHP
}
如果($结果!=)
{
$ C = $页+ 1;
$的col1 [1] =;
$的col1 [2] =#d6e3f6;
$ COL = $的col1 [2];
的foreach($结果为$行)
{
$做= $行['身份证'];
?&GT;
&LT; TR风格=高度:50像素;背景:??&LT; PHP的echo $关口;取代;&GT;
&LT; TD&GT;&LT;输入类型=复选框名称=C1 []值=&LT; PHP的echo $做;&gt;中/&GT;&LT; / TD&GT;
&LT; TD&GT;&LT; PHP的echo $ C;?&GT;&LT; / TD&GT;
&LT; TD&GT;&LT; PHP的echo $行['部门名称'];?&GT;&LT; / TD&GT;
&LT; TD&GT;
&LT;一类=的fancybox fancybox.iframe的href =&LT;?PHP的回声SITE_URL()/设置/ department_edit /".$这 - &GT; hrm-&GT; encData($行['身份证']) ;?&gt;中&GT;&LT; IMG类=艾康SRC =&LT; PHP的回声BASE_URL()'/资产/图像/ edit.png';?&gt;中宽度=20标题=编辑的风格=的margin-top:4PX;保证金左:的3px;&GT;&LT; / A&GT;
&LT; / TD&GT;
&LT; / TR&GT;
&LT; PHP $ C $ = C + 1;
如果($ COL == $的col1 [1])$ COL = $的col1 [2];
否则$ COL = $的col1 [1];
}
?&GT;
&LT; TR风格=高度:50像素;背景:#FFFFFF;字体重量:大胆;&GT;
&LT; TD合并单元格=5的风格=宽度:50像素;&GT;
&LT;输入类型=按钮值=删除级=btn_black的onclick =返回chkdel()&GT;
&LT; / TD&GT;
&LT; / TR&GT;
&LT; PHP}&GT?;
&LT; TR风格=高度:50像素;&GT;&LT; TD合并单元格=4的风格=文本对齐:右;填充右:10px的;&GT;&LT; PHP的echo $链接; ?&GT;&LT; / TD&GT;&LT; / TR&GT;
您已经定义
$配置['格'] ='#list_view';
在你的配置,但你没有定义的容器视图。因此,没有Ajax调用将被发送。
而不是此于是
&LT; TR风格=高度:50像素;&GT;&LT; TD合并单元格=4的风格=文本对齐:右;填充右:10px的;&GT ;&LT; PHP的echo $联系; ?&GT;&LT; / TD&GT;&LT; / TR&GT;
尝试把容器&LT; DIV ID =list_view&GT;&LT; PHP的echo $联系; ?&GT;&LT; / DIV&GT;
如下:
&LT; TR风格=高度:50像素;&GT;&LT; TD合并单元格=4的风格=文本对齐:右;填充右:10px的;&GT ;&LT; DIV ID =list_view&GT;&LT; PHP的echo $联系; ?&GT;&LT; / DIV&GT;&LT; / TD&GT;&LT; / TR&GT;
在分页库还 Jquery_pagination.php
在改变这一行行号184
从
如果(($ curr_offset + $这个 - &GT; per_page)≤($这个 - &GT; total_rows -1))
到
如果(($ curr_offset + $这个 - &GT; per_page)&LT; =($这个 - &GT; total_rows -1))
这将是工作...
Got error in jquery pagination in codeigniter.
if per_page=5;
total number 6 and total page 2
but the pagination like below
Showing 6 to 6 of 6 | < 1 2
But only 5 is shown and last one show in 2nd page.
Hi friends i am stuck in this bug.This show in every pages.Pls give me a solution to get correct pagination
below code is using:
$config['base_url'] = site_url('settings/view_leave_reason_ajax/');
$config['total_rows'] = $this->leav->getLvReasonCount();
$config['per_page'] = 5;
$config['anchor_class'] = 'ajax_links';
$config['show_count'] = true;
$config['div'] = '#list_view';
$this->jquery_pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["links"] = $this->jquery_pagination->create_links();
$data['page'] = $page;
$data['result'] = $this->leav->getLvReason($config["per_page"], $page);
question regarding the below ci pagination:
https://github.com/neotohin/CodeIgniter-Ajax-pagination-Library
view page:
<?php if($result=="")
{?>
<tr style="height: 50px; background:#ffffff; font-weight: bold;">
<td colspan="5" style="width:50px;">
No Details Exist
</td>
</tr>
<?php
}
if($result!="")
{
$c = $page+1;
$col1[1]="";
$col1[2]="#d6e3f6";
$col=$col1[2];
foreach ($result as $row)
{
$did = $row['id'];
?>
<tr style="height: 50px;background:<?php echo $col;?>;">
<td><input type="checkbox" name="c1[]" value="<?php echo $did;?>" /></td>
<td><?php echo $c;?></td>
<td><?php echo $row['department_name'];?></td>
<td>
<a class="fancybox fancybox.iframe" href="<?php echo site_url()."/settings/department_edit/".$this->hrm->encData($row['id']); ?>" ><img class="aicon" src="<?php echo base_url().'/assets/images/edit.png';?>" width="20" title="edit" style="margin-top:4px; margin-left:3px;"></a>
</td>
</tr>
<?php $c=$c+1;
if($col == $col1[1]) $col = $col1[2];
else $col = $col1[1];
}
?>
<tr style="height: 50px; background:#ffffff; font-weight: bold;">
<td colspan="5" style="width:50px;">
<input type="button" value="Delete" class="btn_black" onclick="return chkdel()">
</td>
</tr>
<?php }?>
<tr style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>
You have defined
$config['div'] = '#list_view';
in your config, but you haven't defined that container in your view. Hence no ajax calls will be sent.
So instead of this
<tr style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?php echo $links; ?></td></tr>
Try putting the container <div id="list_view"><?php echo $links; ?></div>
as below:
<tr style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><div id="list_view"><?php echo $links; ?></div></td></tr>
Also in the pagination library Jquery_pagination.php
change this line at line number 184
from
if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )
to
if( ( $curr_offset + $this->per_page ) <= ( $this->total_rows -1 ) )
And it will be working...
这篇关于在CI阿贾克斯jQuery的分页错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!