charles07 3 Posted November 16, 2012 Report 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 Quote Link to post Share on other sites
Edward 108 Posted November 16, 2012 Report 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. Quote Link to post Share on other sites
charles07 3 Posted November 16, 2012 Author Report Share Posted November 16, 2012 got it Yii::app()->clientScript->registerScriptFile('scripts/myfile.js',CClientScript::POS_END); 1 Quote Link to post Share on other sites
Edward 108 Posted November 16, 2012 Report Share Posted November 16, 2012 Did you add that to the controller? Quote Link to post Share on other sites
charles07 3 Posted November 16, 2012 Author Report 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 Quote Link to post Share on other sites
Edward 108 Posted November 16, 2012 Report Share Posted November 16, 2012 Easy as pie. Quote Link to post Share on other sites
Larry 428 Posted November 16, 2012 Report Share Posted November 16, 2012 Yes, that's the best solution. Thanks for sharing it! 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.