Yii Clientscript & Getclientscript

Hi All,

Sorry but i was confuse Yii::app()->clientScript and Yii::app()->getClientScript, both can do the same but when should i use Yii::app()->clientScript/ Yii::app()->getClientScript. Can anyone give me some idea how to differentiate it?

Dear FRIEND

When you call




Yii::app()->clientScript;



It invokes the getter method(__get) and calls




Yii::app()->getClientScript();



I hope I helped a bit.

Regards

Hi seenivasan,

I did try to use to use a script Yii::app()->getClientScript->registerScriptFile(Yii::app()->params[‘STATIC_DOMAIN’] . ‘/javascript/site.js’);

to include the site.js but it return this message ‘Property “CWebApplication.getClientScript” is not defined.’, when i was using Yii::app()->ClientScript->registerScriptFile(Yii::app()->params[‘STATIC_DOMAIN’] . ‘/javascript/site.js’);, it work well. This script actually is write in the component and this component actually is call from layout/main.php page. I just a bit confuse when can i use Yii::app()->clientScript / Yii::app()->getClientScript. In which condition use which is the best?

Dear Friend

You can use




Yii::app()->clientScript;



You can use




Yii::app()->getClientScript();



We can not use




Yii::app()->getClientScript;



This will be treated as property. The property is not existing CWebApplication.

It will not invoke getter method, since there is no getGetClientSCript method.

Regards.

seenivasan,

It that mean actually i can use both in any situation too? no matter the script is in local or external?