> Hi All
>
> I'm trying to load a paging list inside a DIV in another list through ajax
> jQuery. lists view is working perfectly but it seems that for some reason
> jQuery can not load it inside a div in another view!!!
This is how I do pagination with AJAX. First, in the view:
echo $this->element('posts/pagination');
That element contains the entire list of divs or the table, whatever
is being used for display. As long as the table has an ID or there's a
div wrapping everything.
Then, in the controller:
// or use $this->RequestHandler->isAjax()
if ($this->params['requested'])
{
$this->layout = ajax;
/* element becomes the view
*/
$this->viewPath = 'elements'.DS.'posts';
$this->render('pagination');
}
Finally, in the javascript I don't use load(). Instead, I use the
$.ajax() function and replace the element in the success callback:
$('#post_list .PaginationLinks a').click(function(ev)
{
$('#content').loading(); // displays animated GIF
$.ajax({
url: $(this).attr('href'),
cache: false,
success: function(html)
{
$('#content').loading(false);
$('#post_list').replaceWith(html).fadeTo('slow', 100);
}
});
ev.preventDefault();
});
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment