簡體   English   中英

CI中的ajax jquery分頁錯誤

[英]Error in ajax jquery pagination in CI

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

line number 184行更改此行

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

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

它會工作......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM