Saturday, June 23, 2012

Re: Ajax Pagination not working ?

Actually, the pagination is inside the div, I mis-explained in my question, so it must not be this...

This is the full code for info :

//rest of the page

<div id="posts">
 
  <div class="well" style="padding: 20px 10px 20px 10px; font-size: 14px;">
 
  <?php 
  if (empty($posts)) {
  echo("No status yet.");
  } ?>
 
  <?php foreach ($posts as $post): ?>
 
  <?php echo $post['Post']['content']; ?>
     
    <hr>
 
  <?php endforeach; ?>
 
  <?php $this->Paginator->options(array(
     'update' => '#posts',
     'evalScripts' => true,
     'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
     'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
  )); ?>
 
  <div style="text-align: center;">
  <?php 
  if ($this->Paginator->hasPage(2)) {
  echo $this->Paginator->prev();
  echo (" | ");
  } ?> 
  <?php echo $this->Paginator->numbers(); ?> 
  <?php 
  if ($this->Paginator->hasPage(2)) { 
  echo (" | ");
  echo $this->Paginator->next();
  } ?>

  </div>
 
  </div>
 
  </div> <!--/Content-->



Le vendredi 22 juin 2012 18:03:11 UTC+2, JonStark a écrit :
I don't understand why ajax pagination won't work on my app.

In my Users controller :

<?php
class UsersController extends AppController {
public $name = 'Users';
public $helpers = array('Html', 'Form', 'Paginator', 'Js');
public $components = array('RequestHandler');

In my layout :

    <!-- Javascript -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
   
    <!-- Loading gif -->
    <?php echo $this->Html->image('loading.gif', array('id' => 'busy-indicator')); ?> 

And in User/view.ctp

A div with Id "post"

<div id="posts"> Content to paginate  </div

The pagination :

<?php $this->Paginator->options(array(
     'update' => '#posts',
     'evalScripts' => true,
     'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
     'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
  )); ?>
 
  <div style="text-align: center;">
  <?php 
  if ($this->Paginator->hasPage(2)) {
  echo $this->Paginator->prev();
  echo (" | ");
  } ?> 
  <?php echo $this->Paginator->numbers(); ?> 
  <?php 
  if ($this->Paginator->hasPage(2)) { 
  echo (" | ");
  echo $this->Paginator->next();
  } ?>
 
  <?php echo $this->Js->writeBuffer(); ?>
  </div>


 But this ouputs the standard HTML paginator... I'm lost here.

Any idea ? Thanks a lot.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate