yiisoft/yii — Issue #385: CClientScript groups all js scripts using a nested renderPartial in a view
Author: tonydspaniard
Created: 2012-02-22 09:57:24+00:00
State: open

### Scenario
Building a widget that renders a js module realized that its .init() call was performed **X** amount of times even though the code was to be rendered with CClientScript::POS_READY.

After debugging found out that the widget's js code was rendered well when I did the call after the nested renderPartial calls I had within the view file. That is, I realized that the code was 'echoed' to the document every renderPartial call if I had a previos POS_READY, POS_HEAD, etc.., calls.

IMHO the ON_READY calls should be grouped and then echoed to the document and echoed to the document at once. Or at least group them per view even if its a partial view.

### What did I do?
Call a widget to be rendered before the output processed renderPartial

```PHP
widget('mywidget'); ?>
renderPartial(
'//objectviews/_object',
array('data' => $object),
true, true);
}
?>
```
### Result
The widget POS_READY, POS_HEAD, POS_END was processed as many times as the nested renderPartial's javascript code was executed.