hi all ,
i have a question about implementing ‘ClinkPager’ with ajax.
i have a page where i want to display users comments and i’m doing it with CLinkPager.
i extended CLinkPager because i wanted to change the links to be ajax Links with additional params i wanted.
anyway ,
my problem is that i want the ClinkPager to update a DIV (that works) but the ClinkPager Doesnt included inside that div.
so …
i need to change the CLinkPager’s links (just the ones for next and previous) AFTER anyone of the page numbers clicked …
is This possible ??
The Extended CLinkPager’s code is :
class CommentsPager extends CLinkPager{
public $videoID;
protected function createPageButton($label,$page,$class,$hidden,$selected)
{
$perPage = $this->getPageSize();
$startIndex = $page*$perPage + 1;
$beforeSendFunc = <<<EOF
function(){
// $('body').undelegate('#button-PrevTop', 'click');//undelegete the 'click' event ( Yii Ajax BUG)
$(".page").removeClass("selected");//remove selected from current
$(".button-page$page").parent(".page").addClass("selected");
$('#div-Comments').html('').addClass('CommentLoader');
$('body').undelegate('.previous a','click');
$('body').undelegate('.next a','click');
}
EOF;
$SuccessFunc = <<<EOF
function success(data, textStatus, jqXHR)
{
$('#div-Comments').removeClass('CommentLoader').html(data);
}
EOF;
$errorFunc = <<<EOF
error(jqXHR, textStatus, errorThrown)
{
$('#div-Comments').removeClass('CommentLoader').html(textStatus);
}
EOF;
if($hidden || $selected)
$class.=' '.($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE);
return '<li class="'.$class.'">'.CHtml::ajaxLink($label,
Yii::app()->controller->createUrl('GetNextComments',
array(
'startIndex'=>$startIndex,
'maxResults'=>$perPage,
'videoID'=>$this->videoID,
'page'=>$page,
)
)
,array('update'=>'#div-Comments',
'beforeSend'=>$beforeSendFunc,
'success'=>$SuccessFunc
)
,array('class'=>'button-page'.$page)).'</li>';
}
}