renderPartial, multiple jquery downloads.. how to fix?


Thanks to anyone that can help out. I’ve been scouring the forums for a couple days, but haven’t really found a definitive answer to my issues, so I thought I’d ask.

My problem is two fold.

Problem one is that whenever I try to render a view and layout using renderPartial, jquery and jquery.ui are redownloaded everytime I run the renderPartial. Its not an option to set the last value to false, since I need to render the layout to the screen.

Code is like so:

$this->renderPartial(‘requestform’, array(‘model’ => $model), false, true);

I understand the concept of registering scripts, which I do:


But this doesn’t seem to make a difference, it is downloaded everytime I run renderPartial!

Assuming I can solve problem one, problem two would be that sometimes jquery ui takes up to three seconds to download. This happens when I try to do a renderPartial. What is the appropriate yii way to preload jquery or jquery ui prior to it being needed. I understand that the register gets it ready to be used, but it doesn’t seem to actually load it prior to the time that it is needed. I like to have it ready before the on the fly call needs it to be used.

Thanks in advance for any help!


Welcome to the forum.

I would try this:

  1. Register jquery and jquery UI in the initial view.

  2. In the partial view, set both to false in scriptMap.

There may be id clashes when loading the partial (depending on what’s already in the main view or if loaded more than once).



Try with


(without .js at the end of file)

/* moved - not a tip, snippet or tutorial */

I also stumbled upon this problem last week and applied exact similar solution stated by tri.

Sometimes we need to do things ourselves to have better control over flow of application.