php – CI中ajax jquery分页错误

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – CI中ajax jquery分页错误脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
在codeignITer中 jquery分页出错.

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.

朋友,我陷入了这个bug.这个节目在每一页.Pls给我一个解决方案,以获得正确的分页

下面的代码正在使用:

$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);

关于以下ci分页的问题:

https://github.com/neotohin/CodeIgniter-Ajax-pagination-Library

查看页面

<?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>

解决方法

你定义了

$config['div'] = '#list_view';

在您的配置中,但您尚未在视图中定义该容器.因此,不会发送任何ajax调用.

所以不要这样

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><?PHP echo $links; ?></td></tr>

尝试放入容器< div id =“list_view”><?PHP echo $links; ?>< / DIV>如下:

<tr  style="height: 50px;"><td colspan="4" style="text-align: right; padding-right:10px;"><div id="list_view"><?PHP echo $links; ?></div></td></tr>

也在分页库Jquery_pagination.PHP

在第184行更改此行

if( ( $curr_offset + $this->per_page ) < ( $this->total_rows -1 ) )

if( ( $curr_offset + $this->per_page ) <= ( $this->total_rows -1 ) )

它会工作……

脚本宝典总结

以上是脚本宝典为你收集整理的php – CI中ajax jquery分页错误全部内容,希望文章能够帮你解决php – CI中ajax jquery分页错误所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。