clientScript jQuery.getScript functionalities


i stumbled upon this during an attempt to replace some form pages with CJuiDialog. I do

<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(











          'open'=>'js:function() { $("#userprof").load("'.Yii::app()->createUrl('user/profile',array('dialog'=>'')).'"); }'




and open the dialog through array(‘onclick’=>’$("#userprof").dialog(“open”); return false;’) which works perfectly. it even loads the form.

if passed the dialog get option the UserController only renderPartials the form page. so only the content is rendered. so now this profile page loaded contains a CActiveForm and a CJuiDatepicker. These require some js files that may not be loaded on the originating page. But CActiveform for example contains a registerCoreScript call, that inserts its script tag in the head of a rendered HTML page.

with processOutput true the html that is loaded into the Dialog div looks like this.

<link rel="stylesheet" type="text/css" href="/yip/assets/e03b1815/css/base/jquery-ui.css" />

<script type="text/javascript" src="/yip/assets/2de4b930/jquery.js"></script>

<script type="text/javascript" src="/yip/assets/2de4b930/jquery.yiiactiveform.js"></script>



<script type="text/javascript" src="/yip/assets/e03b1815/js/jquery-ui.min.js"></script>

<script type="text/javascript">






the <link> tag has nothing to do within a div and the script calls for jquery overwrite possibly already existing scripts breaking all scripts on the originating page of the load() call.

What i want is something like a clientScript->renderAjax() or sth. that puts out a body code snippet that loads the required and not already loaded scripts(there must be some kind of check for that, css shouldnt be checked that overhead is acceptable as it might be very complicated to check whether a css class exists) at the end of a supplied html string using the jQuery.getScript call.

this could look like

<script type="text/css">

@import url("additional.css");


<script type="text/javascript">


jQuery(document).ready(function() {

if (!isloaded(jqueryui)) {



if (!isloaded(activeform)) {



//rest of scripts like





isloaded() might be some sort of

typeof (function that is declared within script)=='function' 


variable exists or such

that would be a nice feature.

One might also load every existing js and css file on the main layout but i think it would be nice to not have this overhead all the time.

like a register form isnt likely to be used very often.

i would like to hear your opinion about this

best regards keex

PS: i might even imagine some kind of solution using a Yii::app()->clientScript->scriptMap[‘alreadyused.js’] = false; so that every render call constructs an array with already loaded scripts during the last call of that origin(session) and remove them using scriptMap false during a ajax call or such.