php - Cakephp pagination ajax messes up the view -
so after long time , alot of hassle ive made ajax pagination work (sort of)
now html looks this:
<?php $this->paginator->options(array( 'update' => '#content', 'evalscripts' => true, )); ?> <div class="portlet box green report index" id="content"> <div class="portlet-title"> <div class="caption"><i class="icon-globe"></i>report summary</div> <div class="tools"> <a href="javascript:;" class="collapse"></a> </div> </div> <div class="portlet-body"> <table class="table table-striped table-bordered table-hover table-full-width" <thead> <tr> <th><?php echo $this->paginator->sort('offer.name','offer'); ?></th> <th><?php echo $this->paginator->sort('stat.clicks','clicks'); ?></th> <th><?php echo $this->paginator->sort('stat.conversions','conversion'); ?></th> <th><?php echo $this->paginator->sort('stat.payout','payout'); ?></th> <th><?php echo $this->paginator->sort('stat.ltr', 'what-isthis?'); ?></th> <th><?php echo $this->paginator->sort('stat.cpc','expected e-cpc'); ?></th> </tr> </thead> <tbody class="report_data"> <?php foreach ($table['report']['data']['data'] $res): ?> <tr> <td><?php echo h($res['offer']['name']); ?> </td> <td><?php echo h($res['stat']['clicks']); ?> </td> <td><?php echo h($res['stat']['conversions']); ?> </td> <td><?php echo h($res['stat']['payout']); ?> </td> <td><?php echo h($res['stat']['ltr']); ?> </td> <td><?php echo h($res['stat']['cpc']); ?> </td> </tr> <?php endforeach; ?> </tbody> <ul> <?php if ($this->paginator->hasprev()): ?> <li><?php echo $this->paginator->first(__('first')) ?></li> <li><?php echo $this->paginator->prev(__('prev'), array(), null, array('class' => 'prev disabled')) ?></li> <?php endif; echo $this->paginator->numbers(array('currenttag' => 'span', 'currentclass' => 'active', 'separator' => false, 'tag' => 'li', 'modulus' => 5)); if ($this->paginator->hasnext()): ?> <li><?php echo $this->paginator->next(__('next'), array(), null, array('class' => 'next disabled')) ?></li> <li><?php echo $this->paginator->last(__('last')) ?></li> <?php endif ?> </table> </ul> </div> </div> </div> <?php echo $this->js->writebuffer(); ?>
sadly cant show picture (it says im lacking reputation) seems when press paginate puts content of site div block meaning view gets messed alot!
can tell me why doing , how can fix it?
i have tried moving id='content' around different div or table blocks no success
cake version 2.3
my index action
public function index() { if($this->request->is('ajax')) { $this->layout('ajax'); }else{ $this->layout = 'client_layout'; } $startdate = $this->request->data['startdatetime']; $enddate = $this->request->data['enddatetime']; if($startdate == null || $startdate == '' ){ $startdate = date('y-m-d'); $enddate = date('y-m-d'); } array_push($this->paginate['conditions']['stat.date']['values'], $startdate, $enddate); $this->set('table', $this->paginate()); }
update
okay in controller added following:
if ($this->requesthandler->isajax()) { $this->autolayout = true; $this->autorender = true; $this->layout = 'ajax'; }else{ $this->layout = 'client_layout'; }
now helped isnt 100% should be, adding div block ontop of table here html of looks like:
<div id="updatetable"> <div class="portlet box red"> <-- bad!! <div class="portlet-title"> <div class="portlet-body"> </div> <div id="updatetable">
please note changed id updatetable
in controller action pagination link going check request in ajax or not. if request made via ajax tell controller not add header , other css code.
if($this->request->is('ajax')) { $this->layout('ajax'); }
Comments
Post a Comment