Send asset folder path to a javascript of a widget

Comparing #3 with #4

Revision #4 was created by sensorario sensorario on Sep 22, 2011, 7:52:12 AM.

Improve the wiki due to a comment suggestion

Content

[...]
Yii::app()->getClientScript()->registerScript('_', $script, CClientScript::POS_HEAD);
foreach ($scripts as $file)
Yii::app()->getClientScript()->registerScriptFile($file, CClientScript::POS_END);
```

Now, in your script1.js, you can use the variable assetUrl. For example, if you do alert(assetUrl); you'll see the path of this assets, ıe. '/assets/234hn43/'.

 
 
##Important
 
To do this in more widgets or extensions, use unique javascript var name like <extensionName>AssetUrl.