Welcome Guest, Not a member yet? Register   Sign In
JQuery and paging (JQuery question)
#11

[eluser]xwero[/eluser]
Because you are so persistent i've took it upon me to get a working example.

master view file
Code:
<html>
    <head>
        <script src="jquery.js"></script>
        <script>
            $(function(){
                init();
            });
            
            init = function ()
            {
                $('p.paging a').click(function(){
                    var offset = $(this).attr('href');
                    offset = offset.substring(offset.lastIndexOf('/')+1);
                    $.ajax({
                        url: '../ajaxpaging/'+offset,
                        type: 'GET',
                        timeout: 1000,
                        error: function(){
                            alert('Error loading document');
                        },
                        success: function(html){
                            $('body').html(html);
                            init;
                        }
                    });
                    return false;
                });
            }
        </script>
    </head>
    <body>
      <?=$content; ?>
    </body>
</html>
The init is a lambda function so after the ajax request you have the same behavoir

pagepart view file
Code:
<p class="paging">&lt;?=$this->pagination->create_links(); ?&gt;</p>

controller
Code:
class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }

function jqpaging()
    {
        $this->load->library('pagination');
        $this->load->helper('url');

        $config['base_url'] = site_url().'/welcome/jqpaging/';
        $config['total_rows'] = 25;
        $config['per_page'] = 5;
        
        $this->pagination->initialize($config);
        $data['base_url'] = site_url().'/welcome/jqpaging/';
        $data['total_rows'] = 25;
        $data['per_page'] = 5;
        $data['content'] = $this->load->view('jqpagcontent','',true);
        $this->load->view('jqpaging',$data);
    }
    
    function ajaxpaging()
    {
        $this->load->library('pagination');
        $this->load->helper('url');
        
        $config['base_url'] = site_url().'/welcome/jqpaging/';
        $config['total_rows'] = 25;
        $config['per_page'] = 5;
        $this->pagination->initialize($config);
        
        $return = $this->load->view('jqpagcontent','',true);
        echo $return;
    }
}

This only takes care of the paging, you have to add the actual content yourself.

It's a bit easier than i thought.


Messages In This Thread
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 04:36 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 05:14 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 05:16 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 05:44 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 06:09 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 06:13 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 06:38 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 08:11 AM
JQuery and paging (JQuery question) - by El Forum - 11-09-2007, 08:45 AM
JQuery and paging (JQuery question) - by El Forum - 11-10-2007, 12:16 AM
JQuery and paging (JQuery question) - by El Forum - 11-10-2007, 03:48 AM
JQuery and paging (JQuery question) - by El Forum - 11-10-2007, 01:18 PM
JQuery and paging (JQuery question) - by El Forum - 11-10-2007, 01:47 PM
JQuery and paging (JQuery question) - by El Forum - 11-13-2007, 06:28 AM
JQuery and paging (JQuery question) - by El Forum - 11-13-2007, 06:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB