Welcome Guest, Not a member yet? Register   Sign In
How to keep focus on div while using pagination and not refresh the entire page
#1

[eluser]debow[/eluser]
This is the controller code.

Code:
var $data;

    function index($sort_by = 'eorder', $sort_order = 'asc', $offset = 0) {
        
        $limit = 10;
        $data['fields'] = array(
            'rank' => 'Rank',
            'score' => 'Points',
        ); //The above will be sortable columns

        $ranks = $this->rank_model->get_scoring($limit, $offset, $sort_by, $sort_order);

        $data['scores'] = $ranks['rows'];
        $data['num_results'] = $ranks['num_rows'];
        $data['num_pages'] = $data['num_results']/$limit;    
                
        // pagination
        $this->load->library('pagination');
        $config = array();
        $config['base_url'] = site_url("home/index/$sort_by/$sort_order");
        $config['total_rows'] = $data['num_results'];
        $config['per_page'] = $limit;
        $config['uri_segment'] = 5;
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();

        $data['sort_by'] = $sort_by;
        $data['sort_order'] = $sort_order;
        
        $this->load->view('includes/header', $this->data);
        $data['main_content'] = 'home/home_index';
        $this->load->view('includes/template', $data);
    }

This is the view code

Code:
<ul><li>
<div id="tableside" class="tableside">
            <table>
                <tbody>
                    &lt;?php foreach ($fields as $field_name => $field_display): ?&gt;
                    <th>
                        &lt;?php if ($sort_by == $field_name)
                            echo "class=\"sort_$sort_order\"" ?&gt;
                        &lt;?php
                        echo anchor("home/display/$field_name/" .
                                (($sort_order == 'asc' && $sort_by == $field_name) ? 'desc' : 'asc'), $field_display);
                        ?&gt;
                    </th>
                &lt;?php endforeach; ?&gt;

                &lt;?php foreach ($scores as $cmd): ?&gt;
                    <tr>
                        &lt;?php foreach ($fields as $field_name => $field_display): ?&gt;
                            <td>&lt;?php echo $cmd->$field_name; ?&gt;</td>
                        &lt;?php endforeach; ?&gt;
                    </tr>
                &lt;?php endforeach; ?&gt;
                </tbody>
            </table>
</div></li>
<li>
<div id='pages' align='center'>
        &lt;?php if (strlen($pagination)): ?&gt;
                        Pages:
            &lt;?php echo $pagination; ?&gt;
        &lt;?php endif; ?&gt;
</div>
</li>
</ul>


Thanks for any help.
#2

[eluser]Atharva[/eluser]
Use AJAX.
#3

[eluser]debow[/eluser]
Found my answer here. One of the best tutorials I've found for CI.

Just followed vid's 1-5 and have what I want.
http://www.youtube.com/verbloten#p/u/18/ofJRbE5dq10




Theme © iAndrew 2016 - Forum software by © MyBB