Overview ¶
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
Requirements ¶
Yii 1.1 or above
Usage ¶
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);?>
</div>
Use the same method even answering to the ajax request:
if (Yii::app()->request->isAjaxRequest)
$this->renderPartialWithHisOwnClientScript('_sibView', $data);
Maybe I am misunderstand...
But can't you get the same result doing a
renderPartial('view', $data=NULL, false, true)
?
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).
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.