I’ve been helped a great deal studying several of your posts and articles.
I don’t get why some sort of fix hasn’t been incorporated in the framework, but your fix makes it possible for me to use cJuiAutoComplete inside cJuiDialog!
So i double insert jquery. For some requests (such as several zii widgets), loader twice jquery resets some objet and generate a "$.param.querystring is not a function" js error client side.
We have made a custom way to handle a case that’s somewhat related. It’s tied up to jquery mobile, but should be easy to modify to a usual website. jQuery Mobile expects a returned page over ajax to be wrapped in a DIV, and any script outside this div is not usable for us, hence the wrapping. Basically, we never enable processOutput in any of our renders, and this method ensures that scripts are returned.
public function renderPage($view,$params = array(),$options = array(), $return = false, $process = true){
if (!isset($options['id']))
{
$options['id'] = $this->id .'-'.$this->getAction()->id;
}
if (!isset($options['data-role']))
{
$options['data-role'] = 'page';
}
// page div wrapper for jquery mobile
$html = "<!-- page {$options['id']} -->\n";
$html .= CHtml::openTag('div',$options)."\n";
// only process if this is an ajax request
$html .= $this->renderPartial($view,$params,true,Yii::app()->request->isAjaxRequest);
$html .= CHtml::closeTag('div');
$html .= "\n<!-- // page {$options['id']} -->";
// if we do not have a ajax request, render with layout (will also process)
if (!Yii::app()->request->isAjaxRequest)
{
Yii::trace('running renderText');
$html = $this->renderText($html);
}
if ($return){
return $html;
}
else
{
echo $html;
}
}
I liked the idea blux had on the second page, but doing special server-side work really didn’t appeal to me. My solution is to attach to jQuerys filtering methods and do about the same magic there.
I have several controllers which will be called through ajaxlinks. For example home/index, news/index …
Let’s say home/index only includes static content. Now when i change the controller through an Navigation ajaxlink to the controller news/index which includes a CListview with Pagination and ajaxUpdate = true, the pagination with ajax doesn’ t work. It even seems that the css is not properly includes, because the pagingation links are displayed in liststyle.
In the news controller i used the ZController extension from Zach for rendering ajax requests, which solved for me the duplicate ajax requests.
If i call the controller directly news/index with the "renderPartialWithHisOwnClientScript" method from ZController from Zach, the ajax pagination works and also the css is properly working. The css and ajax pagination works also fine, if i click on an pagination link for the first time
If i use the "renderPartial" method i works fine, but then i got the duplicate ajax requests in CListview.
I think the problem is, that while using the "renderPartialWithHisOwnClientScript" method the needed jquery for Clistview pagination is not loaded.
That don’t work because i use the Zcontroller from Zach to avoid the duplicate ajax requests. The statement for the ProcessOutput is ignored when using the renderpartialwithownscript method.