修改ajax分页

This commit is contained in:
Li Jianxuan 2011-10-17 10:20:19 +00:00
parent edf9151e5d
commit 49d6c6e3c1
3 changed files with 46 additions and 23 deletions

View File

@ -453,11 +453,11 @@ class ReviewController extends Zend_Controller_Action
function allreviewAction(){
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$page = $this->_getParam('page');
$uuid = $this->_request->getParam('uuid');
$offset = 5;
$sql = "select r.uuid,r.userid,r.ts_created,u.realname,r.mdcomment,r.conclusion from mdreview r
left join users u on u.id=r.userid
where r.uuid='$uuid'";
@ -467,9 +467,9 @@ class ReviewController extends Zend_Controller_Action
$paginator = Zend_Paginator::factory($rows);
$paginator->setCurrentPageNumber($this->_getParam('page'));
$paginator->setItemCountPerPage(5);
$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
//$paginator->setItemCountPerPage(5);
//$paginator->setView($this->view);
Zend_View_Helper_PaginationControl::setDefaultViewPartial('review/pagination_ajax.phtml');
$list = "";
foreach($rows as $k=>$v)
@ -486,6 +486,10 @@ class ReviewController extends Zend_Controller_Action
$stringbuffer = "<ul class='reviewlist'>$list</ul>";
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
echo $stringbuffer.'<div class="paginator">'.$paginator.'</div>';
}

View File

@ -0,0 +1,26 @@
<?php if ($this->pageCount): ?>
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="javascript:void(0);" onclick="loadmdcomment(<?php echo $this->previous;?>)">&lt; Previous</a>
<?php else: ?>
<span class="disabled">&lt; Previous</span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="javascript:void(0);" onclick="loadmdcomment(<?php echo $page;?>)"><?= $page; ?></a>
<?php else: ?>
<span class="current"><?= $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<a href="javascript:void(0);" onclick="loadmdcomment(<?php echo $this->next;?>)">Next &gt;</a>
<?php else: ?>
<span class="disabled">Next &gt;</span>
<?php endif; ?>
</div>
<?php endif; ?>

View File

@ -104,24 +104,17 @@
<script type="text/javascript" language="javascript">
loadmdcomment();
function loadmdcomment(){
var url = "/review/allreview/uuid/<?php echo $md['uuid'];?>";
function loadmdcomment(page){
var url = "/review/allreview/uuid/<?php echo $md['uuid'];?>/";
var data = '';
$.ajax({
type: "POST",
url: url,
data: data,
success: function(html){
$('#allcomments').html(html);
},
beforeSend:function(){
$('#allcomments').html('正在加载...');
},
/*
complete:function(){
$('#submit').val('提交');
$('#submit').removeAttr('disabled');
}*/
if(page!='')
{
url+='page/'+page;
}
var data = '';
$.ajax({type: "POST",url: url,data: data,
success: function(html){$('#allcomments').html(html);},
beforeSend:function(){$('#allcomments').html('正在加载...');}
});
}
</script>