简体   繁体   中英

How to add JavaScript for a specific controller and action in yii

I am working with an application using Yii. I need to add a JavaScript file for a specific controller and action. What is not necessary to load or add will go in another controller and action. How can I do this?

Put your javascript in a layout or theme and add if you're in right controller.

You can find out your controller name like: Getting Current Controller ID in Yii

and register your javascript if you're in this controller, like @Telvin Nguyen said: Yii - External JS files Inlclude , registerScriptFile and publish

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM