Yii 1.1: zcontroller

This extension provides a new renderPartial method, which renders the clientScript immediatly after the content of the view


This extension provide a new renderPartial method.

This method will render the client script (generated from buttons, dropdown list with auto-submit, zii widget and so on) immediatly after the html of the subiew.

This allow to refresh the subview with his relative clientScript, solving many common problem with ajax-refresh


Yii 1.1 or above


For use the extension, save the file in a folder included by Yii.

When you create a div that will be ajax-refreshed, create like that:

<div id="toRefresh">
<?php $this->renderPartialWithHisOwnClientScript('_sibView', $data);?>

Use the same method even answering to the ajax request:

if (Yii::app()->request->isAjaxRequest)
   $this->renderPartialWithHisOwnClientScript('_sibView', $data);

Total 2 comments

#2107 report it
zaccaria at 2010/11/12 03:09am
Yes, you can

But sometime there are some problem.

Sometime there are some script file that are resended to the browser, and that causes a strange behavior.

Sometime an ajax request is resended many time, the firs time once, the second twice, the third four time and so on.

I usually do renderPartial('view', $data=NULL, false, true), in lot of cases it works well. If I got some problem with repeated scripts, I uses this function that solves the problem.

Only one stuff: it can happen that there will be some id mismatch, in this case the solution is to give manually an id to all clientscripted objects in the subView.

A solution for this second bug is impossible without hacking the framework, because the id generator relies on a constant defined in CHtml (and constant, as they are constant, cannot be changed).

#2100 report it
ricardograna at 2010/11/11 10:31am
Maybe I am misunderstand...

But can't you get the same result doing a renderPartial('view', $data=NULL, false, true) ?

Leave a comment

Please to leave your comment.

Create extension