php - Simple AJAX Pagination with CakePHP does not works -
my pagination ajax not work. trying use cakephp simple ajax pagination. when click next pagination page reload new url this:
http://localhost/restaurante/meseros/index/page:2
i using elements menu. have load jquery on layout:
<?php echo $this->html->script(array('jquery.min.js', 'docs.min.js')); echo $this->html->script(array('bootstrap.min')); ?>
controller:
public $components = array('session', 'requesthandler'); public $helpers = array('html', 'form', 'time', 'js'); public $paginate = array( 'limit' => 3, 'order' => array( 'mesero.id' => 'asc' ) ); /** * index method * * @return void */ public function index() { $this->mesero->recursive = 0; $this->paginate['mesero']['limit'] = 3; //$this->paginate['mesero']['conditions'] = array('mesero.dni' => "34343"); $this->paginate['mesero']['order'] = array('mesero.id' => 'asc'); //$this->paginator->settings = $this->paginate; $this->set('meseros', $this->paginate()); }
index.ctp:
<?php $this->paginator->options(array( 'update' => '#contenedor-meseros', 'evalscripts' => true, 'before' => $this->js->get("#procesando")->effect('fadein', array('buffer' => false)), 'complete' => $this->js->get("#procesando")->effect('fadeout', array('buffer' => false)) )); ?> <div id="contenedor-meseros"> <div class="page-header"> <h2><?php echo __('meseros'); ?></h2> </div> <div class="col-md-12"> <div class="progress oculto" id="procesando"> <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> <span class="sr-only">100% complete</span> </div> </div> <table class="table table-striped"> <thead> <tr> <th><?php echo $this->paginator->sort('id'); ?></th> <th><?php echo $this->paginator->sort('dni'); ?></th> <th><?php echo $this->paginator->sort('nombre'); ?></th> <th><?php echo $this->paginator->sort('apellido'); ?></th> <th><?php echo $this->paginator->sort('telefono'); ?></th> <th><?php echo $this->paginator->sort('created'); ?></th> <th><?php echo $this->paginator->sort('modified'); ?></th> <th class="actions"><?php echo __('actions'); ?></th> </tr> </thead> <tbody> <?php foreach ($meseros $mesero): ?> <tr> <td><?php echo h($mesero['mesero']['id']); ?> </td> <td><?php echo h($mesero['mesero']['dni']); ?> </td> <td><?php echo h($mesero['mesero']['nombre']); ?> </td> <td><?php echo h($mesero['mesero']['apellido']); ?> </td> <td><?php echo h($mesero['mesero']['telefono']); ?> </td> <td><?php echo h($mesero['mesero']['created']); ?> </td> <td><?php echo h($mesero['mesero']['modified']); ?> </td> <td class="actions"> <?php echo $this->html->link(__('view'), array('action' => 'view', $mesero['mesero']['id']), array('class' => 'btn btn-sm btn-default')); ?> <?php echo $this->html->link(__('edit'), array('action' => 'edit', $mesero['mesero']['id']), array('class' => 'btn btn-sm btn-default')); ?> <?php echo $this->form->postlink(__('delete'), array('action' => 'delete', $mesero['mesero']['id']), array('class' => 'btn btn-sm btn-default'), __('are sure want delete # %s?', $mesero['mesero']['id'])); ?> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <p> <?php echo $this->paginator->counter(array( 'format' => __('page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') )); ?> </p> <ul class="pagination"> <li> <?php echo $this->paginator->prev('< ' . __('previous'), array('tag' => false), null, array('class' => 'prev disabled')); ?> </li> <?php echo $this->paginator->numbers(array('separator' => '', 'tag' => 'li', 'currenttag' => 'a', 'currentclass' => 'active')); ?> <li> <?php echo $this->paginator->next(__('next') . ' >', array('tag' => false), null, array('class' => 'next disabled')); ?> </li> </ul> <?php echo $this->js->writebuffer(); ?> </div> <!-- contenedor-meseros -->
Comments
Post a Comment