In an attempt to keep my scripts maintainable, I\'m going to move each into their own file, organised by controller and action:
// scripts which only apply t
I have authored a Plugin for this exact issue.
If you have two files:
it will include the add.js
into the script block of the page.
OR
it will include /js/post/add.js into the script block of the page.
A few cute features are in there and it's simple as beans. You can even use PHP inside your .js files and use viewVars which you set in the action. Most of all, you don't need to hack the view or layout files to make it work, simply fetch the 'script' block in the layout. You can also simply write the .js to another view block.
You can check it out here: https://github.com/dizyart/cakephp-viewautoload
It's in the early stages, so make sure to comment and wishlist!