0

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?

gariepy
  • 3,576
  • 6
  • 21
  • 34
StreetCoder
  • 9,871
  • 9
  • 44
  • 62

1 Answers1

1

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

Community
  • 1
  • 1
Developerium
  • 7,155
  • 5
  • 36
  • 56