Welcome Guest, Not a member yet? Register   Sign In
Pagination links not updating correctly
#1

[eluser]Robert May[/eluser]
Simply put, as you change pages the numbers don't update, and the first page is always the one unclickable.
Now my code for this is a bit...odd and complex, so rather than try to explain what the hell I'm doing I was wondering if anyone could suggest possible causes or solutions that have worked for them before. I've tested without the complexity and it didn't work then either.

In case anyone actually wants to look through it, here's my function. A quick explanation is that I retrieve the pagination links separately using jQuery by passing the POST variable 'huh'='links', but after they've been properly rendered by the pagination library. It grabs the offset via either POST or the URL to allow debugging. And yes, the code is a bit of a mess - I have a deadline of Tuesday and it's a university project based more on functionality, so just ploughing through at the moment! :-)

Code:
function images($what){

        if($what == "list"){

            // load pagination class

            $this->load->library('pagination');

            $this->load->helper('url');

            $config['base_url'] = '/index.php/admin/gallery/images/list';

            $config['per_page'] = 6;

            $config['full_tag_open'] = '<div id="pagination_links"><p>';

            $config['full_tag_close'] = '</p></div>';

            

            if($this->input->post('category')){

                $category = explode('_',$this->input->post('category'),2);

                $category = $category[1];

            }

            else {

                $category = 0;

            }

            

            $this->db->select('*')->from('gallery')->where('image_category', $category);

            $numRows = $this->db->get();

            $config['total_rows'] = $numRows->num_rows();

            

            if(!is_numeric($this->uri->segment(6))){

                $offset = $this->input->post('offset');

                if(!is_numeric($offset)){

                    $offset = explode("/", $offset);

                    $count = count($offset);

                    $count--;

                    $offset = $offset[$count];

                }

            }

            else {

                $offset = $this->uri->segment(6);

            }

            if($offset == NULL){

                $offset = 0;

            }

                

            $this->pagination->initialize($config);

            $images = $this->gallery_model->list_images($category,$config['per_page'],$offset);

            

            if($this->input->post('huh') == 'links'){

                // Create the links seperately for Ajax fun

                echo $this->pagination->create_links();

            }

            else {

                foreach($images as $image){

                    if($image['image_islive'] != 'TRUE'){

                        $islive = '<div class="gallery_admin_image_list_button_isnotlive ui-corner-tl" id="image_'.$image['image_id'].'_islive">Not Live</div>';

                    }

                    else {

                        $islive = '<div class="gallery_admin_image_list_button_islive ui-corner-tl" id="image_'.$image['image_id'].'_islive">Live</div>';

                    }

                    

                    echo '<div class="gallery_admin_upload_image_wrapper" id="'.$image['image_id'].'_'.$image['image_id'].'">

                            <div class="gallery_admin_upload_image_container" id="image_'.$image['image_id'].'">

                                    <ul class="gallery_admin_image_list" id="image_'.$image['image_id'].'_simple">

                                        <li class="gallery_admin_image_list_title">

                                            <div id="image_'.$image['image_id'].'_title" class="admin_input">'.$image['image_title'].'</div>

                                        </li>

                                        <li>

                                            <div><img src="/gallery/'.$image['image_file_squarethumb'].'"></div>

                                        </li>

                                        <li>

                                            <label for="image_'.$image['image_id'].'_islive">Select for multiple actions: &lt;input type="checkbox" id="image_'.$image['image_id'].'_multi" /&gt;&lt;/label>

                                        </li>

                                    </ul>

                                    <ul class="gallery_admin_image_list" id="image_'.$image['image_id'].'_detailed" style="display:none;">

                                        <li class="gallery_admin_image_list_title">

                                            <div id="image_'.$image['image_id'].'_title" class="admin_input">'.$image['image_title'].'</div>

                                        </li>

                                        <li>

                                            &lt;textarea id="image_'.$image['image_id'].'_comment"&gt;Comments/details&lt;/textarea&gt;

                                        </li>

                                    </ul>    

                                </div><div class="gallery_admin_image_list_button ui-corner-tr" id="'.$image['image_id'].'">Details</div>'.$islive.'</div>';

                }

            }

        }

    }


Messages In This Thread
Pagination links not updating correctly - by El Forum - 05-23-2009, 02:27 PM
Pagination links not updating correctly - by El Forum - 05-23-2009, 02:57 PM
Pagination links not updating correctly - by El Forum - 05-23-2009, 07:48 PM
Pagination links not updating correctly - by El Forum - 05-24-2009, 07:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB