renderPartial slows down performance?

I have two versions of the same view, both creating the EXACT same output:


<?php $this -> renderPartial('_form', array('model' => $model), false, true); ?>


<div id="list">


<?php $this -> renderPartial('_list', array('data' => $data), false, true); ?>


</div>

In the first code example, the second call of renderPartial just hides a foreach loop wich in turn call a renderPartial for each object. But this causes the objects to appear one after another in a fairly slow way, which is NOT ok for this little amount of data.


<?php $this -> renderPartial('_form', array('model' => $model), false, true); ?>


<div id="list">


<?php foreach ($data as $model): ?>


<div id="<?php echo $model -> id; ?>">


<div class="guestview <?php echo ($model -> status ? 'inside' : 'outside'); ?>">


<?php echo $model -> name; ?>


</div>


</div>


<?php endforeach; ?>


</div>

Here in the second example everything works fine and all objects just appear at the same time… but I have another view that looks exactly like the first code example just that it does not render the ‘_form’ view and then again everything works fine even tought renderPartial is called many times, if it was for renderPartial then that code would not work as it does so what could it be?

Oops I missread. It has something to do with output buffering. Try to do this when rendering the view (in controller):

echo $this->render(‘view’, array(yourdata…), true);

I don’t know why that should solve the problem since that bool is described as “whether the rendering result should be returned instead of being displayed to end users.”?

If you pass true, all the output is saved into a buffer. When you echo that buffer, everything should be displayed instantly (well at least no one-by-one output).

How do I output that buffer, codewise?


$output = $this->render('view', array(), true);

echo $output;

Strangely enough that creates the same output as just using the render method.

By some reason I had the fourth parameter in ‘renderPartial’ (processOutput) sat to true, which means in my case, that the registered javascript gets recursivly added after each call of ‘renderPartial’ which makes all the trouble…

Hehe that’s explains it :)