charles07 Posted November 16, 2012 Share Posted November 16, 2012 how to include js file in controller ie. some thing like this public function actionIndex() { //load js file here $this->render('index'); } requirement is to load js file in a new page Link to comment Share on other sites More sharing options...
Edward Posted November 16, 2012 Share Posted November 16, 2012 Wouldn't that go in the relevant views file or layouts/main.php header section.. You will probably get faster help on the Yiiframework.com forum as everyone here is just starting to learn Yii. Link to comment Share on other sites More sharing options...
charles07 Posted November 16, 2012 Author Share Posted November 16, 2012 got it Yii::app()->clientScript->registerScriptFile('scripts/myfile.js',CClientScript::POS_END); 1 Link to comment Share on other sites More sharing options...
Edward Posted November 16, 2012 Share Posted November 16, 2012 Did you add that to the controller? Link to comment Share on other sites More sharing options...
charles07 Posted November 16, 2012 Author Share Posted November 16, 2012 yup, public function actionIndex() { Yii::app()->clientScript->registerScriptFile('scripts/myfile.js',CClientScript::POS_END); $this->render('index'); } i just wanted to load this file in a single page, if i load it in layouts/main.php page file would be loaded in entire site. regards charles 1 Link to comment Share on other sites More sharing options...
Edward Posted November 16, 2012 Share Posted November 16, 2012 Easy as pie. Link to comment Share on other sites More sharing options...
Larry Posted November 16, 2012 Share Posted November 16, 2012 Yes, that's the best solution. Thanks for sharing it! 1 Link to comment Share on other sites More sharing options...
Recommended Posts