Using htmloptions() in scriptfiles

I’m inserting JS like this:


Yii::app()->clientScript->registerScript('test',"alert('test')",CClientScript::POS_READY);

But how can I assign an HTML ID attribute to it? (<script id=‘myVal’ …></script>)

I would expect something like this, but it’s obviously not working:


Yii::app()->clientScript->registerScript('test',"alert('test')",

             CClientScript::POS_READY,array("id"=>"myVal");

I’ve searched the API but I couldn’t find anything. What would be the proper way of extending/modifying the clientscript behaviour to make this possible? Has anyone done this before?

it 's not meaningful to giving a script a id : <script id=‘someId’ > …</script> the api is not able to do that ; you may try embed the raw block in you view files . or use CHtml::openTag(‘script’)…

any way you can always use the raw html syntax :D