June 23 2013

Yii include/preload yiigridview javascript

Tagged Under :

Normally we include Javascript in our application in Yii is below script
But, now we need include yiigridview.js script file in our application. Because it was generate by Yii and it located at assets folder. So above example cannot used.

In here, we need to call getAssetManager() to get the assets folder url and folder name generated by Yii.
The above example will get the gridview path from the assets folder.

After that you need to call registerScriptFile() class to include the files you want.

Below example will show you how to use it.
$assetsScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets'));
Yii::app()->getClientScript()->registerScriptFile($assetsScriptUrl .'/gridview/jquery.yiigridview.js');

Make a Comment

You must be logged in to post a comment.