php - Ajax record not rendered completely cakephp -
i have ajax generated cakephp 2.0 paginated record. each time try click next go next page, missing link error.
it works if record generated without ajax.
appcontroller
class appcontroller extends controller { public $helpers = array('session'); public $components = array( 'session','requesthandler', 'email','image','cookie', 'auth' => array( 'loginredirect' => array( 'controller' => 'users', 'action' => 'index' ), 'logoutredirect' => array( 'controller' => 'compass', 'action' => 'index', 'home' ), 'autherror' => 'did think allowed see that?', 'authenticate' => array( 'form' => array( 'passwordhasher' => 'blowfish', 'fields' => array('username' => 'email') ) ) ), ); controller
public function filterprice(){ $this->autorender = false; $this->layout="ajax"; $this->request->onlyallow('ajax'); //can't accessed via http/https if ($this->session->read('conditions.fess')) { $this->session->delete('conditions.fees'); } if ($_request['val'] != 'any') { $this->session->write('conditions.fees', $_request['val'] ); }else{ $this->session->delete('conditions.fees'); } $queryconditions = $this->intialiseconditions(); // echo debug($queryconditions); $this->paginator->settings = array( 'conditions' => $queryconditions + array('school.level'=> $_request['level']), 'limit'=>20, 'order' => array('user.membership'=>'asc','school.name'=>'asc')); $schools = $this->paginator->paginate('school'); $this->set(compact('schools')); $this->render('filtered','ajax'); } my view filtered.ctp
<header class="showing"> <div id="range"> schools:<b><?php echo $this->paginator->counter(array( 'format' => 'range' )); ?> </b> </div> <div id="meet">school<?php echo (count($schools) >1)? 's ':' '?>(<?php echo count($schools); ?>) </div> <div class="counters"> <?php echo $this->paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled')); echo $this->paginator->numbers(array('separator' => ' | ', 'first' => 1, 'last' => 1)); echo $this->paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled')); ?> </div> <div class="clearfloat"></div> </header> my jquery
$('.elementtosort').click(function(e){ $('#ttips').fadeout('slow'); var key = $(this).attr('key'); var val = $(this).attr('value'); var state = $(this).attr('state'); var level = $('#level_holder').val(); //console.log(val); if($(this).hasclass('disabled')) { $(this).removeclass('disabled'); $(this).parent('li').find('ul').fadeout('slow'); $.ajax({ beforesend:function (xmlhttprequest) {$('#overlaybig').fadein(); $('#overlaybig7').fadein(); }, url: "<?php echo router::url(array('controller' => 'schools', 'action' => 'setfilters', 'dowhat'=>'remove'), true); ?>", data:{key:key,value:val, state:state, level:level}, cache: false, type: 'get', datatype: 'html', success: function (data, textstatus) { $("#overlaybig").fadeout(); $("#overlaybig7").fadeout(); $('#right_panel').html(data); }}); // if($(this).hasclas }else{ $(this).addclass('disabled'); $(this).parent('li').find('ul').fadein('slow'); $.ajax({ beforesend:function (xmlhttprequest) {$('#overlaybig').fadein(); $('#overlaybig7').fadein(); }, url: "<?php echo router::url(array('controller' => 'schools', 'action' => 'setfilters', 'dowhat'=>'add'), true); ?>", data:{key:key,value:val, state:state, level:level}, cache: false, type: 'get', datatype: 'html', success: function (data, textstatus) { $("#overlaybig").fadeout(); $("#overlaybig7").fadeout(); $('#right_panel').html(data); }, }) } return false; }
Comments
Post a Comment