How to add javascript to YII correctly?

Posted by RD. on Stack Overflow See other posts from Stack Overflow or by RD.
Published on 2012-11-19T10:55:40Z Indexed on 2012/11/19 11:00 UTC
Read the original article Hit count: 124

Filed under:

I want to create several javascript function that will be needed on different pages. Most will be relevant only to one page, but some to several. I know if I add general conversion functions, it would be a good idea to just create a new javascript file and put all these generic functions into that one file. Bringing me to my first question:

  • Where would you store the generic javascript file? In "protected"? Which subfolder?

Then, I need to address the placement of other javascript code.

  • If I have javascript that will only be used on one page, should I use this technique or should I stick to a similar approach as above?

The emphasis is on doing it correctly. I want to fall exactly in line with the yii framework.

© Stack Overflow or respective owner

Related posts about yii