Perfect...the 
if ($this->RequestHandler->isAjax())
        {
                $this->viewPath = 'elements/users';
                $this->render('pagination');
        } 

Did the trick.

Thanks
Dave

-----Original Message-----
From: brian [mailto:[email protected]] 
Sent: August-11-09 3:42 PM
To: [email protected]
Subject: Re: Pagination Help


If you place the markup that lists the posts in an element, you can specify
to render just that, instead of the entire view, for AJAX requests.

Here's an example that works for me.

views/users/index.ctp:

<h1>Member Directory</h1>

<?= $this->element('users/pagination') ?>



views/elements/users/pagination.ctp:

<table id="user_list">
        <caption></caption>
        <thead>
                <tr>
                        <th><?= $paginator->sort('Name', 'User.last_name',
array('title' => 'sort by last name')) ?></th>
                        <th><?= $paginator->sort('Organization',
'User.organization', array('title' => 'sort by organization')) ?></th>
                        <th><?= $paginator->sort('Country', 'User.country',
array('title'
=> 'sort by country')) ?></th>
                </tr>
        </thead>
        <tfoot>
                <tr>
                        <th colspan="3">
                                <?= $this->element('paginator_links') ?>
                        </th>
                </tr>
        </tfoot>
        <tbody>
<?php
foreach ($users as $user)
{
?>
...
<?php
}
?>
        </tbody>
</table>


users_controller.php:

public function index()
{
        $this->set('users', $this->paginate('User'));
        
        /* render only the element for AJAX requests
         */
        if ($this->RequestHandler->isAjax())
        {
                $this->viewPath = 'elements/users';
                $this->render('pagination');
        }
}


users.js:

$(function()
{
        stripeRows('#user_list tbody');
        initAsyncUserPagination();
});

/**
 * Initialise AJAX requests for the users table.
 * Both the pagination and sort links will be bound so that
 * requests are made asynchronously.
 */
function initAsyncUserPagination()
{
        $('#user_list .PaginationLinks a, #user_list thead
a').click(function()
        {
                $('#user_list').fadeTo('fast', 0.1);

                $('#content').loading(true);
                var href = $(this).attr('href');
                
                /* fetch the form
                 */
                $.ajax({
                        url: href,
                        cache: false,
                        success: function(html)
                        {
                                $('#content').loading(false);
                                
                                /* replace the entire #user_list table
                                 */
        
$('#user_list').replaceWith(html).fadeTo('slow', 100);
                                stripeRows('#user_list tbody');
                                
                                /* call this function again to init new
content
                                 */
                                initAsyncUserPagination();
                        }
                });
                return false;
        });     
}

function stripeRows(selector)
{
        $(selector + ' tr:nth-child(even)').addClass('Odd');    
}


On Tue, Aug 11, 2009 at 1:10 PM, Dave Maharaj ::
WidePixels.com<[email protected]> wrote:
> I have the ajax jquery pagintiion set up no problem.
>
> I am using a default layout,single column for content.
>
> Now when i load the posts page (which has the pagination) the index 
> view is split into 2 columns, right side is menu, left side is the 
> paginator. But when i click next, the 2 column loads into the pagination
div.
>
> I put just the pagination content into an element and load element 
> from the view, click next and it stll loads the full view.
>
> How can only load the pagination into a div. I know it has todo with 
> my index function because it loads the default template which then 
> pulls the index view which has the 2 cols...so when i load the ajax 
> pagination the index function is still pulling the full view.
>
> Dave
> >
>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to