Comment on Best practices for JS and CSS organizationComments−binspace15yI used to organize js binding based on the controller (https://github.com/pivotal/jelly), but found that it is better to base it on the template.There are a few reasons:1. It makes more conceptual sense. The javascript relates to html (which is generated by the template), not a controller action.2. You will probably want to reuse templates across different controllers. Also partial templates can have reusable behavior.3. It is easier to move between the associated javascript + template4. Refactoring is easier, especially with html gotten via AJAX
Comments
I used to organize js binding based on the controller (https://github.com/pivotal/jelly), but found that it is better to base it on the template.
There are a few reasons:
1. It makes more conceptual sense. The javascript relates to html (which is generated by the template), not a controller action.
2. You will probably want to reuse templates across different controllers. Also partial templates can have reusable behavior.
3. It is easier to move between the associated javascript + template
4. Refactoring is easier, especially with html gotten via AJAX